search for: model_1_id

Displaying 1 result from an estimated 1 matches for "model_1_id".

Did you mean: model1_id
2012 Sep 04
5
Associations and Math between Models
I''ve setup two models, 1 and 2, that are associated by has_and_belongs_to_many. I''m trying to get an attribute from model_1 to use in a method in model_2. When I use the code below, I get an error saying ''undefined method model_1_id''. What am I missing? Thanks! Model_2.rb Class Model_2 < ActiveRecord::Base ... has_and_belongs_to_many :model_1 def some_method attr_a * Model_1.find(model_1_id).attr_I_need end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Ta...