Displaying 3 results from an estimated 3 matches for "find_by_description".
2007 Jan 26
6
has_many :through query question
...has_many :upgrades
has_many :accessories, :through => :upgrades
end
class Upgrade
belongs_to :bicycle
belongs_to :accessory
# price defined in table
end
Now my question is, I need to query the upgrades for a bicycle for a
specific accessory.
I was doing this:
accessory = Accessory.find_by_description("headlight")
bike.upgrades.find_by_accessory_id(accessory.id)
but it seems klunky. Is there a better way to perform this kind of
lookup?
Thanks
Jeff
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "...
2009 Feb 09
3
RSpec Testing ActiveRecord config dependency.
I have the following library code:
def normal_time_now
return DateTime.now.utc if default_timezone == :utc
return DateTime.now
end
This is dependent upon a setting in config/environment.rb
# Make Active Record use UTC-base instead of local time
config.active_record.default_timezone = :utc
I want to test that I get the expected results with the config set to
utc and
2006 Mar 05
8
Model Inheritance, Mixins and Database design
I''m trying to understand how best to use inheritance and wonder if
Rail''s Single Table Inheritance model too restricting.
I have a model Companies who provide 1+ Services (HABTM relationship).
I assume the best way to represent this is with a series of child models
representing each type of service : ServiceType < Company.
I want to return lists of companys for each