I just succeed to set in place my rails server. But when I'm trying to add a new "machine" I have an error. I can see this in logs

ActionView::TemplateError (undefined method `owner_id' for #<Machine:0x7f85a0d279e0>) on line #49 of app/views/machines/_form.html.erb:
46: </div>
47: <p>
48:    <%= f_machine.label :owner %><br />
49:    <%= f_machine.collection_select :owner_id, Owner.find(:all), :id, :name, :prompt => "Select an owner"%>
50: </p>
51: <p>
52:    <%= f_machine.label :category %><br />

app/views/machines/_form.html.erb:49
app/views/machines/new.html.erb:4
app/views/machines/new.html.erb:3
app/controllers/machines_controller.rb:35:in `new'
passenger (2.2.15) lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'
passenger (2.2.15) lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:441:in `start_request_handler'
passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:381:in `handle_spawn_application'
passenger (2.2.15) lib/phusion_passenger/utils.rb:252:in `safe_fork'
passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:377:in `handle_spawn_application'
passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `__send__'
passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:163:in `start'
passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:222:in `start'
passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:253:in `spawn_rails_application'
passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:247:in `spawn_rails_application'
passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rails_application'
passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:145:in `spawn_application'
passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:278:in `handle_spawn_application'
passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `__send__'
passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'

Rendering /home/et1/wip3/sophia/public/500.html (500 Internal Server Error)

Machine/new

<h1>New machine</h1>

<% form_for(@machine) do |f_machine| %>
    <%= render :partial => 'form', :locals => { :f_machine => f_machine } %><br />
<p><br />
<%= f_machine.submit 'Create' %>
</p>
<% end %>

  <%= link_to 'Back', machines_path %>

machine/_form:

<%= f_machine.error_messages %><br />
<p>
    <%= f_machine.label :nom %><br />
    <%= f_machine.text_field :nom %>
</p>
<p>
<%= f_machine.label :role %><br />
<select name="machine[role]" title="Select a role">
    <option value="dev">Dev</option>
    <option value="test">Test</option>
    <option value="prod">Prod</option>
    <option value="Support">Support</option>
</select>

</p>

<div class="fields">

<% f_machine.fields_for :ipvfours do |f_ip| %>
    <%= render :partial => 'ipvfours/form', :locals => { :f_ip => f_ip } %>     
<% end %> 
<p>
    <%= link_to_add_fields "Add IPv4 address", f_machine, :ipvfours %>
</p>


<% f_machine.fields_for :ipvsixes do |f_ip| %>
    <%= render 'ipvsixes/form', :f_ip => f_ip %> 
<% end %>

<p>
    <%= link_to_add_fields "Add IPv6 address", f_machine, :ipvsixes %>
</p>



<p>
    <% f_machine.fields_for :macs do |f_ip| %>
        <%= render 'macs/form', :f_ip => f_ip %> 
    <% end %>
</p>
<p>
    <%= link_to_add_fields "Add MAC address", f_machine, :macs %>
</p>

</div>
<p>
   <%= f_machine.label :owner %><br />
   <%= f_machine.collection_select :owner_id, Owner.find(:all), :id, :name, :prompt => "Select an owner"%>
</p>
<p>
   <%= f_machine.label :category %><br />
   <%= f_machine.collection_select :category_id, Category.find(:all), :id, :cat, :prompt => "Select a category"%>
</p>
<br />

I don't really understand why it does not work knowing that in development mode it works.

Thanks in advance for help.

Comments

can we have more output of your view like how you define your form_for ?

Written by shingara

info added in description :)

Written by Goueg83460

Accepted Answer

Have you successfully migrated your database? Is there an owner_id field in the machines table in your production database?

Written by Gareth
This page was build to provide you fast access to the question and the direct accepted answer.
The content is written by members of the stackoverflow.com community.
It is licensed under cc-wiki