【问题标题】:Devise working local but not working on heroku设计在本地工作但不在heroku上工作
【发布时间】:2013-03-29 21:53:02
【问题描述】:

我有一个应用 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

我不知道为什么它说 undefined method name for #&lt;User:0x00000004317050&gt;

【问题讨论】:

  • 您是否在 Heroku 上运行过所有迁移? $ heroku run rake db:migrate:status --app app_name 是否报告任何待处理的迁移?
  • 已修复!我所做的迁移,并没有在我的模型 user.rb...TKS 上创建列名!

标签: heroku devise ruby-on-rails-3.2


【解决方案1】:

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

$ heroku run rake db:migrate

【讨论】:

    猜你喜欢
    • 2014-07-06
    • 1970-01-01
    • 1970-01-01
    • 2014-01-02
    • 1970-01-01
    • 2021-04-26
    • 2015-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多