2010/9/4 Pål Bergström <[email protected]>: > I'm trying to pass a value from a cookie from the controller into model > by using attr_accessor. But it doesn't work and I suspect I do something > wrong. > > Is this on the right path? > > class Test < ActiveRecord::Base > > attr_accessor :key > > .... key .. > > end > > class TestController < ApplicationController > def new > �...@test = Test.new > �[email protected] = cookies[:my_key]
You could alternatively say @my_key = cookies[:my_key] then access @my_key in the view. If the key is logically an attribute of Test then use your method, if you are just putting it there in order to pass it to the view then it may be more logical to use a separate variable. Colin -- 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.

