undefined method `name' for nil:NilClass

41 views
Skip to first unread message

William de Lima

unread,
Jun 29, 2015, 3:02:57 PM6/29/15
to rubyonra...@googlegroups.com
Hi, i'm pretty new to the Rail and Ruby and today I have a problem that I have to solve (tl;dr: the expert ruby/rails has left our company and now the newbies like me have to work on the projects that he left). So, let's go straight:

I have an app running "normally", login function OK, but then when the user try to reach other sections on the site like this one in the error bellow:

Processing by NewsController#show as HTML
  Parameters: {"id"=>"news-alpha-2-3-8"}
  Rendered application/_pagetitle.html.haml (0.1ms)
  Rendered application/_pagetitle.html.haml (0.0ms)
  Rendered news/show.html.haml within layouts/application (2.5ms)
Completed 500 Internal Server Error in 19ms

ActionView::Template::Error (undefined method `name' for nil:NilClass):
    9: .pull-right
    10: = submit_tag t('news.comment'), class: 'btn btn-primary'
    11: .clearfix
    12: - unless @item.comments.any?
    13: #comment-composer= t('news.no_comments')
    14: - else
    15: - @comments.each do |comment|
  app/views/news/show.html.haml:12:in `_app_views_news_show_html_haml___3582658555150926440_64556152601540'

And the "undefined method `name' for nil:NilClass" error appears in other sections as well. If nay of you could explain me why this erros shows up, because i've double checked the database and these fields are ok, do I have to check for more specific errors? Thanks in advance.


Colin Law

unread,
Jun 29, 2015, 3:23:03 PM6/29/15
to rubyonra...@googlegroups.com
On 29 June 2015 at 18:54, William de Lima <perfec...@gmail.com> wrote:
> ..
> ActionView::Template::Error (undefined method `name' for nil:NilClass):
> 9: .pull-right
> 10: = submit_tag t('news.comment'), class: 'btn btn-primary'
> 11: .clearfix
> 12: - unless @item.comments.any?
> 13: #comment-composer= t('news.no_comments')
> 14: - else
> 15: - @comments.each do |comment|
> app/views/news/show.html.haml:12:in
> `_app_views_news_show_html_haml___3582658555150926440_64556152601540'

Is @item nil possibly?

Colin
Reply all
Reply to author
Forward
0 new messages