Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top