Saturday, July 9, 2011

How to list tasks from your project

rake -T

  • Use Rakefile for tasks that operate on the plugin’s source files, such as special testing or documentation. These must be run from the plugin’s directory.
  • Use tasks/*.rake for tasks that are part of the development or deployment of the application in which the plugin is installed. These will be shown in the output of rake ,ÄìT, the list of all Rake tasks for this application.

How to extend a class

class Symbol
  def %(arg)
The above code does what you need, but leaves no hint that you've made a change to Symbol. An alternative solution is to define a module and include that module in Symbol.
module SymbolExtension
  def %(arg)

Symbol.send :include, SymbolExtension

Granted, this isn't a huge hint, but if you check
 Symbol.ancestors you'll find the following list.
extracted from:

plugins on rails 3.0

How to install it?
rails plugin install URL
How to remove it?
rails plugin remove plugin_name
How to create your own plugin?
rails generate plugin my_plugin
The files that are required are:
and directory in the plugin called lib

A few special variables are available to your code in init.rb:
name The name of your plugin ('my_plugin' in our simple example).
path The directory in which the plugin exists, which is useful in case you need to read or write nonstandard files in your plugin’s directory. 
config The configuration object created in environment.rb. (See Chapter 1, “Rails Environments and Configuration,” as well as the online API docs for Rails::Configuration to learn more about what’s available via config.)