Hi, may be a fairly redundant question, as i realize this is not much of a problem as it is lack of knowledge and capability to find some useful information on the net; setting a cookie is easy enough, as i did: cookies["survey_#{@survey.id}"] = {:value => ''abc''} which works fine, as i checked my browser, and it saved it perfectly. i was wondering how i check if the user has that cookie or not. say, in the rhtml i want to block some code if the user has this cookie, namely: <% if cookie["survey_#{@survey.id}"] -%> ..you can''t reach this, you already did the survey.. <% else -%> ...blockofcode <% end -%> but unfortunately the cookie[...] doesn''t work. how do i check if a user has a cookie set in his browser or not? many thanks for an answer or a lead; thx, harp -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
harp wrote:> <% if cookie["survey_#{@survey.id}"] -%> > ..you can''t reach this, you already did the survey.. > <% else -%> > ...blockofcode > <% end -%> > > but unfortunately the cookie[...] doesn''t work.That should be cookies[...] Note the ''s''. Chris --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Chris Mear wrote:> harp wrote: > > > <% if cookie["survey_#{@survey.id}"] -%> > > ..you can''t reach this, you already did the survey.. > > <% else -%> > > ...blockofcode > > <% end -%> > > > > but unfortunately the cookie[...] doesn''t work. > > That should be > > cookies[...]Actually, that''s not the main problem. The main problem is that the ''cookies'' method isn''t accessible from views. You can only access it from your controller. So in your controller, write something like: @completed = cookies["survey_#{@survey.id}"] And then in your view you can do <% if @completed -%> Chris --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
many thanks. i didn''t realize the cookies method wasn''t avaliable in the views... thx, harp -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---