I do something similar, but you only need to remove it from mass assignment
controller
@thing = Thing.new(params[:thing])
@thing.value = "enchilada"
model
attr_accessible :name, :description <===== value cant be mass_assigned
since is done programatically there is no need to validate it
even better create a class method in the model that raises an exception if
it fails and call instead of the save method, in it set the value you want :
)
def selft.supersave!
do the stuff
or raise Exception.new("OMG LOL")
end
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.