1.dos工程路径下执行(c:home/trunk/src下):
ruby script/generatemigration AddPermissionsData(名字随便起)
生成时间戳文件
class AddPermissionsData< ActiveRecord::Migration
def self.up
p = Permission.create({:name => '张三', :parent_id => '367', :deleted => '0', :action => 'schedule', :sort_number => '4'})
end
def self.down
end
end
执行 rake db:migrate
Ok…..
-------------------------------------------------------------------
2.在lib-tasks下新建data_update.rake里面代码
namespace :data_permissions do
//task名online_update随意起
task:online_update => :environment do
Model:Permission,向表Permissions插数据
p =Permission.create({:name => '张三', :parent_id => '367', :deleted=> '0', :action => '/schedule', :sort_number=> '4'})
end
end
执行:rake 文件名:task名
rake data_permissions:online_update
成功!(版本低)
高版本用:rails g migration add_data_to_p
转载于:https://blog.51cto.com/qihoushangshu/1409326