添加新列这是我的用户model.rbRails的DB不迁移
class User < ActiveRecord::Base
attr_accessor :password
attr_accessible :email, :name
validates :name,:presence=>true,:length=>{:maximum=>15}
validates :email,:presence=>true,:length=>{:maximum=>15}
end
我想添加密码的新列。 我用命令
rails g migration pass_mig password:string
然后
rake db:migrate
但DB模式仍然
ActiveRecord::Schema.define(:version => 20130627073430) do
create_table "users", :force => true do |t|
t.string "name"
t.string "email"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end
Rails中
而且控制台:密码不能在IE浏览器中的一个新的用户对象添加新的数据库条目..请建议。 P.S:我是新手,所以这可能是一个愚蠢的问题。我正在使用rails版本:3.2.13和ruby版本:1.9.3
你还应该检查和编辑生成器生成的任何迁移文件,然后再执行它们。 – tadman
嘿,非常感谢。“神奇”是。你也可以请告诉最好的地方来学习一些其他的魔法大会。 – user2526795
user2526795你会想要按照@tadman上面提到的建议。并研究Bachan Smruty发布的代码。在rails中做大部分事情有多种方式。 –