save inserts null instead of actual values

Sanjeev Bb wrote:

Sanjeev Bb wrote:

Saving an instance of a model class inserts null values or zeros
instead of the actual values
Code below has some lines commented since I noticed a thread
where one individual encountered a similar situation but no
confirmed solution was identified.

Eliminating my access methods in the model solved the problem.

Hi Sanjeev

ActiveRecord uses a hash, @attributes, to hold attribute values, and provides 'magic' accessors to those values (using method_missing) if you haven't provided your own accessors.

If you wish to write your own accessors, use read_attribute and write_attribute to access the attribute values in the hash.

See http://railsmanual.com/class/ActiveRecord%3A%3ABase#read_attribute

regards

   Justin