This Ruby on Rails problem is a bit vexing, as the code works fine locally but not when I push it onto my live server.
I’ve added a few int columns into a table using a migration and have a few checkboxes to determine whether items of a certain status are displayed on a certain page, eg:
status\page myitems featureditems saleitems
status1 X x x
status2 x x
This works fine locally in a development environment, but when I push the code to my live server the “add new feature” page fails to load with the following error:
Started GET "/admin/statuses/new" for 86.159.115.236 at 2012-08-19 13:39:12 -0400
Processing by Admin::StatusesController#new as HTML
Rendered shared/_validationerror.html.erb (0.0ms)
Rendered admin/statuses/_form.html.erb (2.1ms)
Rendered admin/statuses/new.html.erb within layouts/application (2.2ms)
Completed 500 Internal Server Error in 4ms
ActionView::Template::Error (undefined method `show_my_items' for #<Status:0xb6c1690>):
20: </tr>
21:
22: <tr>
23: <td align="center"><%= f.check_box :show_my_items %></td>
24: <td align="center"><%= f.check_box :show_latest_items %></td>
25: <td align="center"><%= f.check_box :show_featured_items %></td>
26: <td align="center"><%= f.check_box :show_search_results %></td>
app/views/admin/statuses/_form.html.erb:23:in `block in
_app_views_admin_statuses__form_html_erb__566719799_79558060'
app/views/admin/statuses/_form.html.erb:1:in
`_app_views_admin_statuses__form_html_erb__566719799_79558060'
app/views/admin/statuses/new.html.erb:7:in
`_app_views_admin_statuses_new_html_erb__880262090_94647510'
app/controllers/admin/statuses_controller.rb:31:in `new'
In this case ‘show_my_items’ is one of the fields attached to a status, (represented by page1).
Additionally, on live I can edit a status using the checkbox (but it’s int datatype…), but on live, though I can view the edit page and submit without an error, it doesn’t actually update the field.
So the columns exist in the database, the code is the same code as I have on live, but the error only happens on the live server. Same version of Rails on both (3.1.0.rc8), ruby versions slightly different (local: 1.9.2p320, live: 1.9.3p194).
No idea what’s going on…
Well the problem seems to be that Passenger did not start correctly. Either it takes longer than I thought or something else went wrong, but having restarted passenger again it worked fine.