On Jul 20, 2014, at 10:04 PM, huon sothon wrote:
> Hi everybody
> i am new developer in ROR. now i have one question to ask?
> 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
> 26
> 27
> 28
> 29
> 30
> 31
>
>
>
> <li><a href="/">Home</a></li>
>
> <li><a href="#">Products</a>
>
> <ul class="dropdown-menu">
>
> <% @categories.each do |category| %>
>
> <li><a href="#"><%= category.category_name %></a>
>
>
>
> <ul class="dropdown-menu">
>
>
>
>
> please help me!
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
>
>
> --
> 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 rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/aebbb661-5553-480b-b0f4-3e6a8907381c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/EECBB704-9C12-41FC-B9AD-8881E816762F%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment