设计本地工作但不在heroku上工作

时间:2013-04-07 22:21:59

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

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

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

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

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

适用于sign_in页面!

这是我的routes.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>

1 个答案:

答案 0 :(得分:1)

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

$ heroku run rake db:migrate