1

这是我的观点,问题发生在哪里:

<div class="row" style="margin-top:10%;">
    <div class="four columns"></div>
    <div class="four columns">      
        <div class="panel">
            <h2>Criar conta</h2>
            <%= simple_form_for resource, :as => resource_name, :url => registration_path(resource_name), defaults: { error_html: { class: 'alert label' } } do |f| %>
                <div><%= f.input :name, :autofocus => true, :placeholder => "Nome", label: false %></div>
                <div><%= f.input :email, :placeholder => "E-mail", label: false  %></div>
                <div><%= f.input :password, :placeholder => "Senha", label: false  %></div>
                <div><%= f.input :password_confirmation, :placeholder => "Confirme sua senha", label: false  %></div>
                <div align="center">
                    <%= f.submit "Cadastrar", :class => "button success" %>
                </div>
            <% end %>
            <p><%= link_to "Já tenho conta", new_session_path(resource_name) %></p>
        </div>
    </div>
    <div class="four columns" style="margin-top:10%;"></div>
</div>

这是错误消息:

ActionView::Template::Error (undefined method `name' for #<User:0x00000003ecda80>):
2013-02-13T18:40:43+00:00 app[web.1]:     4:        <div class="panel">
2013-02-13T18:40:43+00:00 app[web.1]:     5:            <h2>Criar conta</h2>
2013-02-13T18:40:43+00:00 app[web.1]:     6:            <%= simple_form_for resource, :as => resource_name, :url => registration_path(resource_name), defaults: { error_html: { class: 'alert label' } } do |f| %>
2013-02-13T18:40:43+00:00 app[web.1]:     7:                <div><%= f.input :name, :autofocus => true, :placeholder => "Nome", label: false %></div>
2013-02-13T18:40:43+00:00 app[web.1]:     8:                <div><%= f.input :email, :placeholder => "E-mail", label: false  %></div>
2013-02-13T18:40:43+00:00 app[web.1]:     9:                <div><%= f.input :password, :placeholder => "Senha", label: false  %></div>
2013-02-13T18:40:43+00:00 app[web.1]:     10:               <div><%= f.input :password_confirmation, :placeholder => "Confirme sua senha", label: false  %></div>
2013-02-13T18:40:43+00:00 app[web.1]:   app/views/devise/registrations/new.html.erb:7:in `block in _app_views_devise_registrations_new_html_erb___2903664484468264557_32844520'
2013-02-13T18:40:43+00:00 app[web.1]:   app/views/devise/registrations/new.html.erb:6:in `_app_views_devise_registrations_new_html_erb___2903664484468264557_32844520'
2013-02-13T18:40:43+00:00 app[web.1]: 
2013-02-13T18:40:43+00:00 app[web.1]: 

这是 Heroku (pg:psql) 表的一部分,以确保创建了该列:

name                   | character varying(255)      | 
 status                 | boolean                     | 
 confirmed_at           | timestamp without time zone | 
 confirmation_token     | character varying(255)      | 
 confirmation_sent_at   | timestamp without time zone | 

我跑rake db:version

赫罗库:20130213174735

本地:20130213174735

4

1 回答 1

2

完成 a 后,heroku run rake db:migrate您需要执行 aheroku restart以便 Rails 重新缓存 activerecord 结构。

于 2013-02-13T22:40:36.443 回答