Displaying 1 result from an estimated 1 matches for "versioned_sprockets".
2010 Feb 11
3
Parameterized ActiveRecord Associations: Any such thing?
...many specifically).
I''m wondering if such a thing exists or, if not, if anyone else has an
elegant, equivalent solution?
Example:
class Sprocket < ActiveRecord::Base
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...