aboutsummaryrefslogtreecommitdiffstats
path: root/railties/doc/guides/source/creating_plugins/tasks.txt
blob: c71ba42bb0db1ed529ecf826d1adff1b5dfcb08e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
== Rake tasks ==

When you created the plugin with the built-in rails generator, it generated a rake file for you in 'vendor/plugins/yaffle/tasks/yaffle.rake'.  Any rake task you add here will be available to the app.

Many plugin authors put all of their rake tasks into a common namespace that is the same as the plugin, like so:

*vendor/plugins/yaffle/tasks/yaffle.rake*

[source, ruby]
---------------------------------------------------------
namespace :yaffle do
  desc "Prints out the word 'Yaffle'"
  task :squawk => :environment do
    puts "squawk!"
  end
end
---------------------------------------------------------

When you run `rake -T` from your plugin you will see:

---------------------------------------------------------
...
yaffle:squawk             # Prints out the word 'Yaffle'
...
---------------------------------------------------------

You can add as many files as you want in the tasks directory, and if they end in .rake Rails will pick them up.

Note that tasks from 'vendor/plugins/yaffle/Rakefile' are not available to the main app.