我有一个应用程序http://agile2go.herokuapp.com/使用 devise + cancan。
在本地运行应用程序工作正常,但部署在 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>
最佳答案
我刚刚遇到了同样的问题 - raking
为我解决了这个问题。在控制台中尝试一下:
$ heroku run rake db:migrate
关于heroku - 设计在本地工作但不在heroku上工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15868544/