Heroku运行迁移但仍无法识别该列

时间:2013-02-13 19:25:54

标签: ruby-on-rails heroku migration

这是我认为问题出现的观点:

<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

Heroku:20130213174735

本地:20130213174735

1 个答案:

答案 0 :(得分:2)

完成heroku run rake db:migrate之后,您需要执行heroku restart,以便Rails重新记录activerecord结构。