0

Possible Duplicate:
DEPRECATION WARNING on save with ruby and active_record

I have the following simple piece of code that assigns event type (which is a model) to my event model:

def event_type=(new_event_type)
  self.event_type_id = new_event_type.id
  write_attribute(:event_type, new_event_type)
end

It works fine, however after upgrading to Rails 3.2 I get the following message:

You're trying to create an attribute event_type'. Writing arbitrary attributes on a model is deprecated. Please just useattr_writer` etc.

The warning is at "write_attribute" line.

Any suggestion why this warning is happening and what's the best way to address it would be appreciated.

Kind Regards.

2
  • I've only seen that happen when you have forgotten to migrate your database. Have you ensured that the database is up to date? Jan 9, 2013 at 23:10
  • @ChrisCashwell, I've checked the migrations and they are all up to date. As for the possible duplicate question, I'm not 100% sure that what I need is the attr_accessor. Would I need it for every single attribute on my model as described in the answer for that question?
    – alexs333
    Jan 9, 2013 at 23:27

0

Browse other questions tagged or ask your own question.