Re: [Rails] Using ActiveRecord Find with associations

2010-09-04 Thread Colin Law
On 4 September 2010 01:27, Pito Salas wrote: > Here's an example: > > class LineItem < ActiveRecord::Base >  belongs_to :order > end > > class Order < ActiveRecord::Base >  has_many :line_items > end > > my_line_item = LineItem.find(:zipcode => "12345") > > Order.find_by_line_item(my_line_item) #

[Rails] Using ActiveRecord Find with associations

2010-09-03 Thread Pito Salas
Here's an example: class LineItem < ActiveRecord::Base belongs_to :order end class Order < ActiveRecord::Base has_many :line_items end my_line_item = LineItem.find(:zipcode => "12345") Order.find_by_line_item(my_line_item) # doesn't work Order.find_by_line_item_id (my_line_item) # does wor