nbarraille
nbarraille

Reputation: 10023

Rails 3 create model with temporary argument

I have a model that needs to rename a file when being created. In order to keep my controller skinny, this is done in the after_validation method of my model. I don't want this argument stored in the DB, I just need to access it in the after_validation model.

The problem is that when from my controller I call Model.create(:my_temp_arg => "blahh") I get the Can't mass-assign protected attributes error.

How can I do this?

Thanks!

Upvotes: 0

Views: 90

Answers (1)

iouri
iouri

Reputation: 2929

You need to add it to attr_accessible list and attr_accessor:

attr_accessor :my_temp_arg
attr_accessible :other fields, :my_temp_arg

Upvotes: 1

Related Questions