Displaying 1 result from an estimated 1 matches for "callers_condit".
2010 Feb 11
3
Parameterized ActiveRecord Associations: Any such thing?
...e
belongs_to :widget
belongs_to :version
end
class Widget < ActiveRecord::Base
has_many :sprockets
has_many :versioned_sprockets, lambda do |v|
:conditions => { :version => v }
end
end
The idea behind the example is so I can do stuff like:
def get_just_the_sprockets_i_need(callers_conditions)
version = Version.find(magic_method_returning_just_the_right_id)
widget = some_other_magic_method_returning_a_widget_instance
widget.versioned_sprockets(version).all(:conditions =>
callers_conditions)
end
I first considered just putting a named scope directly in the Sprocket
class, g...