There are some issues already included in Station I want to blog, because I think they are interesting.
One of them is ActiveRecord::Content::Inquirer
In Station, a container is an ActiveRecord model that have many contents, like posts, images, videos, bookmarks, etc.. What if you want to obtain all the contents in a Container using just one SQL query? And you also want to paginate them? And, of course, getting back instances of every Content!
ActiveRecord::Content::Inquirer does just this. You use it:
ActiveRecord::Content::Inquirer.all :container => somespace,
:page => params[:page],
:per_page => 10
It even accepts an Array in :container.
Some of the magic is under this hack:
class Inquirer < ActiveRecord::Base
@colums = Array.new
@columns_hash = { "type" => :fake }
...
end
This way, it’s possible to use ActiveRecord::Base goodies without a real table in the database.