On Friday, 29 August 2014 15:01:41 UTC-4, António wrote:
>
> Dear all,
>
>  
>
> I am a new "Ruby/Ruby on Rails" programmer. I am not sure this is the 
> correct forum for my question. If this is not the correct forum, please 
> indicate me a more appropriate one.
>
>  
>
>  
>
> When my application implements a URL, an array, @session, is used in 
> several methods of a first controller. The application redirects to another 
> page, making a second controller being invoked. This controller does not 
> use the array. When the method of the second controller ends, a layout is 
> implicitly rendered. The layout has the following code:
>
>  
>
> ...
>
> <body>
>
>         <% if @session.length == 0 then %>
>
> ...
>
>  
>
> I got the following error message when trying to implement the URL: undefined 
> method `length' for nil:NilClass.
>
>  
>
> What should I do in order to the array be recognized by the second 
> controller?
>
>  
>

Controllers and their instance variables are torn down after each request; 
setting @session in one won't have any effect on subsequent requests.

You may want to look into the built-in `session` helper, which uses signed 
cookies:

http://guides.rubyonrails.org/action_controller_overview.html#session

The Guides site overall will be very useful to you.

--Matt Jones
 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/f791faa7-2699-49c8-a794-5330e5cc00df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to