Search code examples
ruby-on-railsruby-on-rails-3ruby-on-rails-4locomotivecms

Learning Rails 3 after having learnt Rails 4


I'm new to Rails, having only built two sites with it. So far I've only used Rails 4.0. I now want to start using LocomotiveCMS but it doesn't support Rails 4 yet. Since I'm starting a new project I don't have to worry about downgrading existing code to be compatible with Rails 3, but obviously if I start using Rails 3 as if it was Rails 4 I'm going to run into some problems.

  1. What changes do I need to be aware of in switching to Rails 3 so that the code I write doesn't break down due to being Rails 4-specific? I've read the 4.0 Release Notes but without knowing what the changes are based off of I can't be sure of what to expect when going in reverse. For example, Rails 3 mass assignment protection is deprecated. That makes it clear that I've been using a Rails 4-specific implementation for mass assignment protection and so I should stop using that, but it doesn't indicate what the original system was in Rails 3, so I can't tell what I need to change to.
  2. How many of these changes will affect what I'm able to deliver to the client as opposed to just providing better performance or cleaner code? For example, not having Turbolinks makes page loads feel less quick to the client, but neither they nor I are likely to notice the lack of Russian Doll Caching.
  3. Is there anything that would make it just plain unwise to switch back to Rails 3 for some reason? For example, security concerns, or things that just simply cannot be done in Rails 3 that can be done in Rails 4?

Understanding the answers to these questions will make it possible to make an informed decision about how to make the switch and whether or not it's even worth making the switch. Since LocomotiveCMS uses Mongoid I'll be learning to use it instead of ActiveRecord, but I don't know if that helps or hinders.


Solution

  • Rails 4 is generally nicer and cleaner than 3.2, but 3.2 is nicer and cleaner than 3.0. Going backward should be fine, just be prepared to run into rough edges.

    • Read the upgrade guide. Pay special attention to stuff that was removed or replaced.
    • If there's a feature in 4 that you desperately need, there's probably a gem that backports it to 3.2 (turbolinks works with Rails 3.2, for instance)
    • Pay attention to the Rails maintenance policy. 3.2 is still getting security fixes, but older versions aren't.