Ruby on rails (用户:0x00000005f63ee8>;的未定义方法`name';);RubyonRails 3.2.1

Ruby on rails (用户:0x00000005f63ee8>;的未定义方法`name';);RubyonRails 3.2.1,ruby-on-rails,ruby,ruby-on-rails-3,devise,Ruby On Rails,Ruby,Ruby On Rails 3,Devise,我在heroku日志中有以下错误: 也许这是因为我在注册时添加了姓名和电话字段?在本地,我的项目运行良好,没有问题 用户模型: class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniautha

我在heroku日志中有以下错误:

也许这是因为我在注册时添加了姓名和电话字段?在本地,我的项目运行良好,没有问题

用户模型:

class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and   :omniauthable
devise :database_authenticatable, :registerable,
     :recoverable, :rememberable, :trackable, :validatable

# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :surname, :phone
end
class用户
设计注册表格:

<div id="content">  
<h1 class="title">Reģistrēt jaunu profilu.</h1>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="virslauks"> 
    <span class="text2">
        <%= f.label :name, "Vārds:" %><br />
        <%= f.text_field :name %><br />
        <%= f.label :surname, "Uzvārds:" %><br />
        <%= f.text_field :surname %><br />
    </span>
</div>
<div class="virslauks"> 
    <span class="text2">
        <%= f.label :phone, "Telefona Nr.:" %><br />
        <%= f.phone_field :phone %>
    </span>
</div>
<div class="virslauks"> 
    <span class="text2">
        <%= f.label :email, "E-pasts:" %><br />
        <%= f.email_field :email %>
    </span>
</div>
<div class="virslauks"> 
    <span class="text2">
        <%= f.label :password, "Parole:" %><br />
        <%= f.password_field :password %><br />
        <%= f.label :password_confirmation, "Vēlreiz parole:" %><br />
        <%= f.password_field :password_confirmation %>
    </span>
</div>
<%= f.submit "Reģistrēties" %>
<% end %>

这是我的荣幸。
资源名称:url=>注册路径(资源名称))do | f |%>









设计\创建\用户:

class DeviseCreateUsers < ActiveRecord::Migration
  def change
create_table(:users) do |t|
  ## User details
  t.string :name,               :null => false, :default => ""
  t.string :surname,            :null => false, :default => ""
  t.integer :phone,            :null => false, :default => ""

  ## Database authenticatable
  t.string :email,              :null => false, :default => ""
  t.string :encrypted_password, :null => false, :default => ""

  ## Recoverable
  t.string   :reset_password_token
  t.datetime :reset_password_sent_at

  ## Rememberable
  t.datetime :remember_created_at

  ## Trackable
  t.integer  :sign_in_count, :default => 0
  t.datetime :current_sign_in_at
  t.datetime :last_sign_in_at
  t.string   :current_sign_in_ip
  t.string   :last_sign_in_ip

  ## Encryptable
  # t.string :password_salt

  ## Confirmable
  # t.string   :confirmation_token
  # t.datetime :confirmed_at
  # t.datetime :confirmation_sent_at
  # t.string   :unconfirmed_email # Only if using reconfirmable

  ## Lockable
  # t.integer  :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
  # t.string   :unlock_token # Only if unlock strategy is :email or :both
  # t.datetime :locked_at

  ## Token authenticatable
  # t.string :authentication_token


  t.timestamps
end

add_index :users, :email,                :unique => true
add_index :users, :reset_password_token, :unique => true
# add_index :users, :confirmation_token,   :unique => true
# add_index :users, :unlock_token,         :unique => true
# add_index :users, :authentication_token, :unique => true
  end
end
classdeveliecCreateUsersfalse,:default=>
t、 字符串:姓氏,:null=>false,:default=>“”
t、 整数:phone,:null=>false,:default=>
##数据库可验证
t、 字符串:email,:null=>false,:default=>
t、 字符串:加密密码,:null=>false,:default=>
##可恢复
t、 字符串:重置密码\u令牌
t、 日期时间:重置密码发送时间
##难忘的
t、 datetime:记住在
##可追踪
t、 整数:计数中的符号,默认值=>0
t、 日期时间:当前登录时间
t、 日期时间:上次登录时间
t、 字符串:ip中的当前\u符号\u
t、 字符串:ip中的最后\u签名\u
##可加密
#t.string:password\u salt
##可证实
#t.string:确认令牌
#t.datetime:已确认
#t.datetime:确认发送至
#t.string:未确认的电子邮件#仅当使用可再确认
##可锁
#t.integer:failed_尝试,:default=>0#仅当锁定策略为:failed_尝试时
#t.string:unlock_token#仅当解锁策略为:email或:两者皆有时
#t.datetime:locked_在
##可认证令牌
#t.string:authentication\u令牌
t、 时间戳
结束
添加索引:users,:email,:unique=>true
添加索引:users,:reset\u password\u token,:unique=>true
#添加索引:users,:confirmation\u token,:unique=>true
#添加索引:users,:unlock\u token,:unique=>true
#添加索引:users,:authentication\u token,:unique=>true
结束
结束
问题已解决:

我已经解决了这个问题。我只是加了一句

添加索引:用户,:姓名,:姓氏,:电话


在designe\u create\u users中,
name
是数据库中的一列吗?注意,默认情况下,
designe
中不存在该选项。如果是这样,您是否运行了
rake db:migrate

是的,我在本地运行了
rake db:migrate
,但在heroku控制台
heroku运行db:migrate
,所以一切都应该正常了……正如您所看到的,我的用户表中有name列。