Reputation: 1590
namespace :mails do
desc "Send emails"
task :send_emails => :environment do
User.not_deleted.find_each do |user|
Notifier.confirm_about_paid_access(user.id).deliver
end
end
desc "Free subscription for users registered in 2011"
task :free_subscription_for => :environment, :year do |t, args|
year = args[:year]
users = User::registered_in(year)
end
end
displaying error: lib/tasks/mails.rake:10: syntax error, unexpected keyword_do_block, expecting => task :free_subscription_for => :environment, :year do |t, args|
What is incorrect in syntax code?
Upvotes: 1
Views: 65
Reputation: 1268
Try this,
namespace :mails do
desc "Send emails"
task :send_emails => :environment do
User.not_deleted.find_each do |user|
Notifier.confirm_about_paid_access(user.id).deliver
end
end
desc "Free subscription for users registered in 2011"
task :free_subscription_for, [:year] => :environment do |t, args|
year = args[:year]
users = User::registered_in(year)
end
end
Notice the syntax for :free_subscription_for
task.
And while executing the task the syntax would be rake mails:free_subscription_for["2016"]
Hope this helps!
Upvotes: 1