I have a model Widget that accepts :title, :url, :description as user input via a front-end form.
In this model, I ultimately don’t care about the :url (meaning I don’t want to store it). What I do care about however are 2 pieces of data in the :url, an :appname and a username.
On the otherhand, i DONT want :appname and :username to be mass-assigned or accessible in any way to the public (to make it simple, its very hard to validate them due to the source continually changing). What I do is validate the URL strictly and that is enough, and where those parts are in the url i have much more lax rules in the regex).
I’m not sure how to set this up though in the model itself. This is what I have so far
attr_accessible :description, :title, :url
However, how do I write :username and :appname if they aren’t attr_accessible?
If you want only to write non ActiveRecord attributes to your model instance you can use
in your model.
Or use
if you want to set/get it later to/from active_record
:urlattribute.