Created
January 13, 2012 04:50
-
-
Save kazukeyan/1604733 to your computer and use it in GitHub Desktop.
"rake db:seed:x" to CRUD operation from db/seeds/x.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
namespace :seed do | |
Dir::glob("db/seeds/*.rb").each do |file| | |
target = File.basename(file, ".rb") | |
desc 'CRUD operation from "db/seeds/'+target+'.rb"' | |
task target => :environment do | |
require file | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
db/seeds 以下にデータ操作系のスクリプトを配置しておけば、db:seed:ファイル名でtaskを作成してくれるrakeファイル