Showing C:/railsapp/facepro/app/views/layouts/application.html.erb where line #28 raised:
undefined method `each' for nil:NilClass
Extracted source (around line #28):
25 26 27 28 29 30 31 |
|
On Jul 20, 2014, at 10:04 PM, huon sothon wrote:
> i am using devise for authentication.it is work very well .but when i select data (category or sub_category) from database in app/views/layouts/application.html.erb and then i click sign_in it show errors as shown below:
>
> NoMethodError in Devise::Sessions#new
>
> Showing C:/railsapp/facepro/app/views/layouts/application.html.erb where line #28 raised:
>
> undefined method `each' for nil:NilClass
> Extracted source (around line #28):
> 25: <li><a href="/">Home</a></li>
> 26: <li><a href="#">Products</a>
> 27: <ul class="dropdown-menu">
> 28: <% @categories.each do |category| %>
> 29: <li><a href="#"><%= category.category_name %></a>
I'm not sure what Devise has to do with this specifically. Have you looked to see what if anything is in the @categories variable? It sounds as though it's nil, by the error. It should be at least an array if you want each to work. What does this view's controller method look like? (Copy and paste, please.)
Walter