2

我有一个使用 devise + cancan的应用程序http://agile2go.herokuapp.com/ 。

在本地运行应用程序可以正常运行,但是当部署在 Heroku 上时,sign_up页面会显示错误消息。但是,登录页面工作正常!

我知道问题是在 simple_form_for 中调用资源时,当我取出资源时它起作用了:

<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'form-horizontal' }) do |f| %>

它在sign_in页面上工作!

这是我的路线.rb

authenticated :user do 
  root :to => "home#index"
end
root :to => "home#index"     
devise_for :users, :path => "auth"

单击链接时在导航栏上:

<li><%= link_to 'Login', new_user_session_path %></li>//works
<li><%= link_to 'Sign up', new_user_registration_path %></li>//does not work  

最后 Heroku 记录:

2013-04-07T21:55:15+00:00 app[web.1]: Started GET "/auth/sign_up" for 177.143.148.73 at    2013-04-07 21:55:15 +0000
2013-04-07T21:55:16+00:00 app[web.1]: 
2013-04-07T21:55:16+00:00 app[web.1]:     4: <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => {:class => 'form-horizontal' }) do |f| %>
2013-04-07T21:55:16+00:00 app[web.1]: ActionView::Template::Error (undefined method `name' for #<User:0x00000004317050>):
2013-04-07T21:55:16+00:00 app[web.1]:     5:   <%= f.error_notification %>
2013-04-07T21:55:16+00:00 app[web.1]:     9:   <%= f.input :password, :placeholder => 'Password', :required => true, input_html: { class: 'text_field input-xlarge' } %>
2013-04-07T21:55:16+00:00 app[web.1]:     10:   <%= f.input :password_confirmation, :placeholder => 'Confirmation', :required => true, input_html: { class: 'text_field input-xlarge' } %>
2013-04-07T21:55:16+00:00 app[web.1]:     8:   <%= f.input :email, :placeholder => 'Email', :required => true, input_html: { class: 'text_field input-xlarge' } %>
2013-04-07T21:55:16+00:00 app[web.1]:     7:   <%= f.input :name, :placeholder => 'Name', :autofocus => true, input_html: { class: 'text_field input-xlarge' } %>
2013-04-07T21:55:16+00:00 app[web.1]:   app/views/devise/registrations/new.html.erb:7:in `block in _app_views_devise_registrations_new_html_erb__4395295283282032383_35150600'
2013-04-07T21:55:16+00:00 app[web.1]:   app/views/devise/registrations/new.html.erb:4:in `_app_views_devise_registrations_new_html_erb__4395295283282032383_35150600'
2013-04-07T21:55:16+00:00 app[web.1]: 
2013-04-07T21:55:16+00:00 app[web.1]:     6:   <%= display_base_errors resource %>  
2013-04-07T21:55:16+00:00 app[web.1]: 
2013-04-07T21:55:16+00:00 heroku[router]: at=info method=GET path=/auth/sign_up host=agile2go.herokuapp.com fwd="177.143.148.73" dyno=web.1 connect=2ms service=228ms status=500 bytes=643

我不知道为什么它说未定义name的方法#<User:0x00000004317050>

4

1 回答 1

2

我刚刚遇到了同样的问题 -raking为我解决了这个问题。在你的控制台中试试这个:

$ heroku run rake db:migrate
于 2015-03-04T16:35:55.787 回答