I’m trying to do up a rails form_for that includes a checkbox for :terms_and_conditions (with validates_presence_of). terms_and_conditions has not been declared as a column in the corresponding database table.
At the moment, when I submit the form and try to create a new model with MyModel.new(params[:mymodel]), I get an *’unknown attribute: terms_and_conditions’* error.
So, just wondering: how do I run create a field for a column – and run validations on it – without inserting that field into the database?
Many thanks…
You need a virtual attribute for terms_and_conditions in your model.
Take a look at this screencast