2010/7/26 Pål Bergström [email protected]:
Sorry but I don’t understand you. And I have a feeling you don’t
Let me ask you this instead; is there a way to get the value of a cookie
in a model?
That breaks encapsulation. The model should never care what your
cookies are doing. Only controllers should care about cookies.
That being said…
When you use the model to create an instance of an ActiveRecord
object, generally you will pass in the params from a form, something
User.create( params[:user] )
params is a type of hash, and Hash has merge. So you can add stuff to
the params before passing it to the model, something like:
params.merge( :my_cookie => cookies[:my_cookie] )