In my Rails application, I have two models: Estimate and Client , which are related to belongs_to State (as in the US).
If I create a simple hash, for example:
properties = {:state => State.first}
... I can create a client in the Rails console as follows:
c = Client.new(properties)
... and it appears with state_id 1 , as expected.
However , if I try to do this with Estimate, for example:
e = Estimate.new(properties)
... it never sets state_id , so I cannot save the association.
The tables for Estimate and Client have the same state_id columns ( int 11 ). The connection is the same. The State object is the same.
What could be the reason for this difference?
Update
This problem was attr_accessible , as Misha pointed out. Another sign that we found was that Estimate.state = State.first returned NoMethodError: undefined method state=
Chris source share