Leave a comment

Avoid Common mistakes in Ruby on Rails Development

Pretty nice write up. I never saw the find_each before. Will have to try that out 🙂


Many programmers face similar problems over and over. So, here I am going to list out the common mistakes that can be avoided in Ruby on Rails Development.

1. Database column Indexing
At the beginning of programming , mostly during writing migrations, we forget to add indexes , which may or may not have any effect in initial stages of application, but will have drastic delay in fetching records from the database as the table size increases.

2. ActiveRecord transaction for saving multiple object
Whenever saving multiple objects in a single request, always use ActiveRecord::Base::transaction method to support atomicity. So, if any record has not saved the entire transaction, will get rolled back and nothing will be saved into the database.
Always add indexes to the column being used for searching records.

ActiveRecord::Base.transaction do
  @tasks.each do |task|

3. Using delete_all instead of destroy_all
ActiveRecord::Base::delete_all or…

View original post 1,031 more words

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: