应用程序在开发模式下工作,但不在生产模式下

时间:2010-10-07 07:33:52

标签: ruby-on-rails production

我刚刚成功设置了我的rails服务器。但是,当我试图添加一个新的“机器”时,我有一个错误。我可以在日志中看到这个

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)

机/新

<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 %>

机/ _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 />

我真的不明白为什么知道在开发模式下工作起作用不起作用。

提前感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

您是否成功迁移了数据库?生产数据库的owner_id表中是否有machines字段?