문제

I have very strange error only in Rails production environment. In development works good. The logs show error in this line in my index.html.erb file.

This is the production log error:

ActiveRecord::RecordNotFound (Couldn't find Person without an ID):
  app/views/seeds/index.html.erb:71:in `block in _app_views_seeds_index_html_erb__4016841983995682700_31529840'
  app/views/seeds/index.html.erb:61:in `each'
  app/views/seeds/index.html.erb:61:in `_app_views_seeds_index_html_erb__4016841983995682700_31529840'
  app/controllers/seeds_controller.rb:17:in `index'

The line in my seed index file is this one:

<td><%= Person.find(seed.person_id).name %></td>

Before this line I query other data in the same way with foreign key and it works. When I check the sql table I see that the Seeds table has the person_id value.

Moreover, when I query the same thing via the rails console in production environment i receive the result without any problems. But when I load the page it shows me "The page you were looking for doesn't exist." and the production.log shows the error above... Any ideas what might be wrong?

도움이 되었습니까?

해결책

Sorry guys after a whole day of coding by brain was not to good. The point is that in the middle of the table I had a NULL object for person and that was causing the error... Thank you for your time

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top