checking cookies

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

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