Showing posts with label plugin. Show all posts
Showing posts with label plugin. Show all posts

Monday, February 22, 2010

Rails plugins and gems

In each rails project, there is a folder named gems and plugins. They are lib files needed for the project. You can install a gem or a plugin into plugins folder. For example, if you want to install will-paginate, you can run the following in the command prompt windows. Then, your rails will recognize the gem:
$ gem install will_paginate
Successfully installed will_paginate-2.3.12
1 gem installed
Installing ri documentation for will_paginate-2.3.12...
Installing RDoc documentation for will_paginate-2.3.12...


However, when you share this lib of the project with others, others need to install the gem. But, if you put the lib into your project, others do not need to install the gem. Therefore, since rails 2.1, you can put the lib into the plugins folder with the follwing command:
$ ./script/plugin install git://github.com/mislav/will_paginate.git

Then, you can find the lib folder as follows: your_project/Vendor/plugins/will_paginate

Friday, February 19, 2010

how to install plugin in rails project

You need to install plugins into your project. It is very simple once you know it. If you have the following error, it is because you don't have a plugin "acts_as_tree".

Error message:
undefined method `acts_as_tree' for #

In your model:
class Post < ActiveRecord::Base
acts_as_tree :order => "name"
end

In the command line windows/termial of your project directory, you can run the followin command:
./script/plugin install acts_as_tree

That is it. Now you don't see the error. And you should have "Vendor\plugins\acts_as_tree"