- Single Responsibity Principle (SRP).
- Skinny Controller, Fat Model.
- Use OpenStruct in your search
- Have too many things like post.creatable_by?(user), give cancan a try.
- Try to make your app really REST
- Tired of keep doing
@post = Post.find(post_id)
in your actions? Check out decent_exposure
-
Tired of going to schema.rb to see your table schema? Use annotate gem
-
Use batched finder to large data query
Just don't write something like this:
#Let's say you have 10000 users in your User table User.all.each do |user| NewsLetter.email(user).deliver end
Use batched finder instead
User.find_in_batches(:batch_size => 5000) do NewsLetter.email(user).deliver end
- When you generate a new migration, double-check by using rake db:migrate, rake db:migrate:redo
- Don't use time_ago_in_words
- As a Rubyist, you should always know Enumerable
- Pulling your hair with working days? Give business_time a try.
- Holidays? There is a gem
- Organising your locales folder
- Use Rails Lazy look-up for page_title
- Raise missing tranlation errors in your test
- Find all missing translations in your app
- Wanna have friendly URL, friendly_id can help.
- Language switching (http://example.com/en/about-us). Try this
- Font doesn't work on Heroku? See this:
- Use rake spec:[controllers|features|models] to run examples in specified directory