Ruby on Rails Development Tips

Neelkanth Ram

1 min read

Its been a couple of months that I started developing commercial projects using Ruby on Rails. Here are some stuff I learned which might be a good practices for aspirant Ruby/Rails developers.

Always use migrations for creating tables or updating tables.

When I was learning ROR, I didn’t used migrations but relied on MySql query browser for creating and updating tables. Using this way if you change your database server or shift to Postgres you have to create the tables again. The best way to avoid this is to make use of migrations in Rails
Migrations is one of the coolest feature in Rails. It is database independent and helps you to maintain different versions of database scripts. Altogether it helps you to handle evolving database and application development.

Don’t touch schema.rb

Dont try to change anything in schema.rb. If you do it will cause some unnecessary problems for you. Infact think schema.rb file is invisible to your eyes. 😉

Use an IDE

Developing a web application using ROR is indeed faster but it will be much easier and faster with the help of an IDE.
We use Netbeans for our ROR projects and happy with it so far.
Some times you test your app manually until you have automated tests for your code, so IDE helps to resolve any errors since you can see the log in the IDE screen itself and you can go to the line number where the error occurred.
For testing Ajax in your web application, use Firebug (an addon for Firefox) console.
Also check this link if you are interested to comparing various ROR IDE’s

Find useful plug-ins and gems

When I was working on an application I wrote my own logic to implement a specific feature but later I came across with certain plugin which can do the same thing in a better way. Try to browse in Internet for the feature you going to implement in your application first before writing it yourself, because most of the times you can find a plugin or gem to implement your feature in a more elegant way.
In the book “Advanced Rails Receipes“, you may also find useful plug-ins which would be used in many scenarios.

Avoid unneccessary restart of webrick server

When you make some changes in your code you dont need to restart your webrick. Webrick can detect the changes without a restart. Only when you modify environment.rb (a configuration file) or when you generate a new controller or you added a new plugin you need to restart the server.

Try to find what’s new in Rails

You might be learning ROR from some books and other sources, but its better you see what’s new with Rails since it is rapidly expanding as they are releasing so many cool featuers with every release.
You might also find Ryan Scraps interesting.
Also the GITHub is full of cool new plug-ins submitted and updated by many ruby/rails developers.

BTW, recently I finished watching the presentation by Martin Fowler in QCon Conference 2009 on the topic “Ruby at Thought Works”. Checkout this link which cover some development tips as well.
Finally, I would be more happy if some of you can also share your development or best practices tips posted as a comment to this blog.

Related posts:

One Reply to “Ruby on Rails Development Tips”

Leave a Reply

Your email address will not be published. Required fields are marked *