views:

58

answers:

2

Hi any one tell me how can i create a component in RoR

A: 

See the official Getting Started with Ruby tutorial.

Dolph
A: 

In rails, "components" come in two flavours: plug-ins and gems.

The first step on creating a new plug-in or gem is: looking for an existing one that already does what we want! Try to avoid reinventing the wheel.

For instance, "logins"(a.k.a. authentication) can already be handled by devise and authlogic gems. If you also want to handle authorization (different permissions for different users), there's cancan and declarative_authorization.

If after looking for them you can't find what you are looking for, you can start creating your own.

The first step on that case is creating a github project with the name of the component, and placing a init.rb file and a lib folder inside it, with all the needed files. In the case of gems, you will also need to create a gemspec file.

This railscast explains in detail how to create a gem.

egarcia