model 代码:
class Keyword < ActiveRecord::Base
validates :name, :presence => true, :uniqueness => true
end
migrate 代码
class CreateKeywords < ActiveRecord::Migration
def change
create_table :keywords do |t|
t.string :name, :null => false
t.integer :level, :null => false, :default => 0
t.timestamps
end
end
end
这 2 者的声明有什么不同吗?如何使用呢?