Re: [Rails] Associations and Math between Models

2012-09-05 Thread Hassan Schroeder
On Tue, Sep 4, 2012 at 9:53 AM, sacshu wrote: > When I use the code below, I get an error saying > 'undefined method model_1_id'. What am I missing? Thanks! > Class Model_2 < ActiveRecord::Base > ... > has_and_belongs_to_many :model_1 > > def some_method >attr_a * Model_1.find(model_1_id).at

[Rails] Associations and Math between Models

2012-09-05 Thread sacshu
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 < Activ