I am trying to write a custom rake task for my app. But however simple my rake task is, rake -T still does not list it. Here''s my file in /lib/tasks called try.rake: desc "try rake" task :one do puts "task one" end and therefore when I run rake try.one I get the "Don''t know how to build task ''try,one''... Anything else need to be configured to get custom rake task to work? Please help. Thanks! -- Posted via http://www.ruby-forum.com/.
For creating rake tasks, you need to first create a namespace.The following
is an example of how to do what you want to do :
namespace :tasks do
    desc "try rake"
    task :one => :environment do
    puts "task one"
    end
end
Once you have this in your try.rake file in /lib/tasks
when you do a rake -T , it will show you your custom rake tasks in the
following way :
rake tasks:one
and that is how you need to call it to execute the rake task as well.
I hope that helps.
Thanks & Regards,
Dhruva Sagar.
Marie von
Ebner-Eschenbach<http://www.brainyquote.com/quotes/authors/m/marie_von_ebnereschenbac.html>
- "Even a stopped clock is right twice a day."
On Mon, Aug 31, 2009 at 11:29 AM, kevin lee <
rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:
>
> I am trying to write a custom rake task for my app.  But however simple
> my rake task is, rake -T still does not list it.  Here''s my file
in
> /lib/tasks called try.rake:
>
> desc "try rake"
> task :one do
> puts "task one"
> end
>
> and therefore when I run rake try.one I get the "Don''t know
how to build
> task ''try,one''...  Anything else need to be configured to
get custom
> rake task to work?
> Please help.  Thanks!
> --
> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Kevin,> /lib/tasks called try.rake: > > desc "try rake" > task :one do > puts "task one" > endAssuming the file is named "#{RAILS_ROOT}/lib/tasks/try.rake", all this is fine. You don''t need to use namespaces if you don''t want to.> Don''t know how to build task ''try,one''You should have a task named "one" showing up in the -T list, ''try'' will not be part of the task name unless you specify a namespace. Bryan
Thanks & Regards, Dhruva Sagar. Joan Crawford<http://www.brainyquote.com/quotes/authors/j/joan_crawford.html> - "I, Joan Crawford, I believe in the dollar. Everything I earn, I spend." On Tue, Sep 1, 2009 at 4:59 AM, Bryan <bryan.a.ash-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Kevin, > > > /lib/tasks called try.rake: > > > > desc "try rake" > > task :one do > > puts "task one" > > end > > Assuming the file is named "#{RAILS_ROOT}/lib/tasks/try.rake", all > this is fine. > > You don''t need to use namespaces if you don''t want to. > > OK, my bad, I thought in order to be part of -T list, you need to have anamespace.> > Don''t know how to build task ''try,one'' > > You should have a task named "one" showing up in the -T list, ''try'' > will not be part of the task name unless you specify a namespace. > > Bryan > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---