{:limit => 30,:string =>“提示:”,:null => false}的未定义方法`to_sym':哈希

时间:2016-06-14 16:01:06

标签: ruby-on-rails

当我尝试运行rake db:migrate时,为什么会显示此错误:

undefined method `to_sym' for {:limit=>30, :string=>"Hint: ", :null=>false}:Hash

代码:

def up
     create_table :users do |t|
            t.string "email", :limit => 50, :string => "Forgot password!", :null => false
            t.column "password", :limit => 30, :string => "Hint: ", :null => false
            :default 

            t.timestamps
        end
      end

1 个答案:

答案 0 :(得分:1)

此行可能需要更改..

t.column "password", :limit => 30, :string => "Hint: ", :null => false

通过

t.string "password", :limit => 30, :string => "Hint: ", :null => false