Monday, March 26, 2012

[Rails] Re: Rails 2.x: load custom task defined in a gem

Hi,

For new custom rack task you have to write rake file under the location
Project/lib/tasks/sample.rake

In that sample.rake file

desc "This task is back-end ruby script added for cron job"
task :cron => :environment do
# put some logic.
end

Go to your console put the command #> bundle exec rake -D

It will return rake tasks which are used in your project.

For example, here you will get your task

rake cron
This task is back-end ruby script added for cron job

Run it using #> bundle exec rake cron


andrea longhi wrote in post #1053442:
> Hello,
>
> I'm writing a nice gem which incorporate a few rake tasks, but I can't
> find a way to add my custom tasks to the application rake list, if the
> app is rails 2.x. I googled for a while but without any luck... any
> hints?
>
> Thanks
>
> Andrea

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate