Created
November 22, 2019 15:11
-
-
Save tacitphoenix/b6ec73218f4fe568c014c4cb97a29dd6 to your computer and use it in GitHub Desktop.
Pass arguments to rake tasks in rails
This file contains 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 :rails_rakes do | |
desc "say hi" | |
task :hi => :environment do | |
puts "Hi" | |
end | |
desc "say hi with arg" | |
task :hi_with_arg, [:name] => :environment do |t, args| | |
puts "Hi #{args[:name]}" | |
end | |
desc "say hi with args" | |
task :hi_with_args, [:name, :age] => :environment do |t, args| | |
puts "Hi #{args[:name]} you are #{args[:age]}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment