0

我一直在尝试在 heroku 上部署一个应用程序,但遇到了很多问题。我目前的问题是,在注册时,我得到一个未定义的方法,声称电子邮件不是 Mate 对象的已定义函数。我跑了

heroku run rake db:migrate

heroku restart

这似乎不能解决问题。此外,当我进入 heroku 终端并查看一个新的 Mate 对象时,它具有 email 属性。这是我的heroku日志:

2013-07-14T22:38:29.637842+00:00 app[web.1]: Processing by HomeController#index as HTML
2013-07-14T22:38:29.650497+00:00 app[web.1]:   Rendered home/index.html.erb within layouts/application (9.1ms)
2013-07-14T22:40:36.729670+00:00 app[web.1]: Started POST "/houses" for 71.202.122.134 at             2013-07-14 22:40:36 +0000
2013-07-14T22:40:36.803157+00:00 app[web.1]: Processing by Houses::RegistrationsController#create as HTML
2013-07-14T22:40:36.803157+00:00 app[web.1]:   Parameters: {"utf8"=>"✓", "authenticity_token"=>"Fsl63CocaqA04/vhoDC0sU/CCSd2YGasqudyCleDNbc=", "house"=>{"address"=>"90 Castro", "city"=>"San Francisco", "email"=>"zyskowski.rob@gmail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
2013-07-14T22:40:37.085467+00:00 app[web.1]: Redirected to http://frozen-spire-1369.herokuapp.com/mates/sign_up
2013-07-14T22:40:37.085467+00:00 app[web.1]: Completed 302 Found in 282ms (ActiveRecord: 0.0ms)
2013-07-14T22:40:37.266161+00:00 app[web.1]: Processing by Mates::RegistrationsController#new as HTML
2013-07-14T22:40:37.276199+00:00 app[web.1]:   Rendered mates/registrations/new.html.erb within layouts/application (8.2ms)
2013-07-14T22:40:37.088159+00:00 heroku[router]: at=info method=POST path=/houses host=frozen-spire-1369.herokuapp.com fwd="71.202.122.134" dyno=web.1 connect=1ms service=368ms status=302 bytes=118
2013-07-14T22:40:37.282256+00:00 heroku[router]: at=info method=GET path=/mates/sign_up host=frozen-spire-1369.herokuapp.com fwd="71.202.122.134" dyno=web.1 connect=1ms service=42ms status=500 bytes=643
2013-07-14T22:40:37.278470+00:00 app[web.1]:     24:                     <div class="controls">
2013-07-14T22:40:37.278470+00:00 app[web.1]:     27:                </div>
2013-07-14T22:40:37.278470+00:00 app[web.1]:     28:    
2013-07-14T22:40:37.278470+00:00 app[web.1]: ActionView::Template::Error (undefined method `email' for #<Mate:0x007f2d5d8efc88>):
2013-07-14T22:40:37.278470+00:00 app[web.1]:     23:                     <%= f.label :email, :class => "control-label" %>
2013-07-14T22:40:37.278470+00:00 app[web.1]: 
2013-07-14T22:40:37.256850+00:00 app[web.1]: Started GET "/mates/sign_up" for 71.202.122.134 at 2013-07-14 22:40:37 +0000
2013-07-14T22:40:37.278470+00:00 app[web.1]:   app/views/mates/registrations/new.html.erb:25:in `block in _app_views_mates_registrations_new_html_erb___482835816309687038_69916399610600'
2013-07-14T22:40:37.276313+00:00 app[web.1]: Completed 500 Internal Server Error in 10ms
2013-07-14T22:40:37.278470+00:00 app[web.1]:     22:                 <div class= "control-group">
2013-07-14T22:40:37.278470+00:00 app[web.1]:     25:                          <%= f.text_field :email, :placeholder => "email" , :autofocus => true %>
2013-07-14T22:40:37.278470+00:00 app[web.1]:     26:                     </div>
2013-07-14T22:40:37.278704+00:00 app[web.1]:   app/views/mates/registrations/new.html.erb:9:in `_app_views_mates_registrations_new_html_erb___482835816309687038_69916399610600'
2013-07-14T22:40:37.278704+00:00 app[web.1]: 
2013-07-14T22:40:37.278704+00:00 app[web.1]: 

我很坚持这里,所以任何想法都非常感谢!谢谢!

4

1 回答 1

0

我猜email在您遇到错误的任何视图中都是空白的。在您的视图中写下这样的内容:

<%= @user.email if @user.email? %> 
于 2013-07-14T23:55:06.107 回答