In ActiveRecord models you can specify custom SQL-request for has_many associations. For example,
class User < AciveRecord::Base
has_many :events, :finder_sql => 'SELECT something complex'
end
While user.events returns what I need, the number of records returned can be huge, so I need to have a way to pass parameters for LIMIT. Is there such a way?
The only solution I found yet is to create events(start, count) method instead and call Event.find_by_sql in it.
In case finder_sql doesn't allow doing this, what is it useful for?