I think this is a good place to start. It tells you the first steps, it's not exhaustive but it gives you a great starting point. http://railscasts.com/episodes/415-upgrading-to-rails-4?view=asciicast
Another 'getting started' guide: http://pivotallabs.com/rails-4-upgrade/
This the exhaustive official upgrade guide. It's well worth reading through in it detail. This may take several days. There will be changes described in there, that did not apply to AEA. This document only captures how the Rails 4 upgrade worked for AEA. http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html
A big change like this, where everything is examined, and QAed, is a good time to do other slightly ambitious stuff.
For AEA we did:
-
General cleanup. We deleted about 2,000 lines of code!
-
Normalize syntax and indentation standards. NF policy is to double indent (4 spaces) private and protected methods.
-
Reorganize: views that were only used in views/staff were moved into view/staff/shared. We had a discussion about where non-model classes belong -- in lib or app/models. KS said 'app/model's and had the winning argument, his was basically what this blog post says.
Be aware of the closed PR from the AEA Rails 4 upgrade, it is the source of most of this information and a great resource.
-
Rails 4 updates assets pipeline and the assets Gemfile group is no longer necessary. Therefore, move gems related to assets outside of the assets group, and delete the assets group.
-
bcrypt-ruby gem is now just bcrypt
-
We need specific version of sass-rails: 4.0.3 -- symptom was, the asset_pipeline assets were missing their digest, so, application.css vs application-23qefa3rqwfease.css example change
PUT becomes PATCH, in general: documentation example changes
-
I ran the
rake rails:upgrade
task and, transitioned over all the config / init files to their Rails 4 formats. example changes ... don't forget about config/environments/staging.rb. -
The lines that load the Gemfile in application.rb have become more terse. documentation
-
config/initializers/secret_token.rb becomes config/secrets.yml example change ... don't forget about staging environment when creating secrets.yml.
-
I renamed the script folder to bin as per Rails 4 upgrade guides. This also moved the script/delayed_job into bin/delayed_job -- these paths might be in some monitoring or capistrano pieces. example change
-
In Rails 4 ALL scopes must have lambdas. This is because, for one example, if there now a Time.now in the scope, it would get set at boot time, and never change. This was a very hard problem to figure out since, in dev mode the file is frequently reloaded. :(
-
We had a discussion regarding the use of "spiky lambdas"--that's
->
vslambda
--we decided we wanted to stick with thelambda
spelled out. -
The behavior of .sum has changed. It's not defined on ActiveRecord in the same way. In some changes we had to change to .to_a.sum example changes
-
The Model.scoped method is deprecated. Now, use Model.all. It returns an ActiveRecord::Relation, which is what you want. discussion argument where folks who say '.all' can replace, win
-
Model.includes(:other_model) must chain a .references call, if the included model is used in a .where SQL statement. discussion example changes
In Rails v4, we should use #includes just like we always have. But in addition, if there is a #where that references one of the included tables, then you must also use #references or it will break. If the #where clause doesn't exist or does not reference an included table, then the #includes alone will do the trick and it will not break.
-
'whitelisted parameters' are now required. This is a big change that we're all familiar with.
-
You can no longer pass :include as an option to a Model.find method. This is part of the larger change "Rails 4.0 has deprecated the old-style hash based finder API. This means that methods which previously accepted "finder options" no longer do." You could search for :include to find that. example changes
-
All methods "find_by_x" are deprecated.
Rails 4.0 deprecates the :confirm option for the link_to helper. You should instead rely on a data attribute (e.g. data: { confirm: 'Are you sure?' }). This deprecation also concerns the helpers based on this one (such as link_to_if or link_to_unless). https://github.com/novafabrica/eventstore/commit/41b948d08efdffc19d0d2cad577298092c39772f
- See the bit about sass-rails above.
-
The way that Capistrano handles the bin directory has changed. See Github issue in capistrano-bundler gem
-
Related to this are changes in the capistrano-novafabrica gem.
This guide looks good to me. @FotoVerite and @meesterdude, please take a look and either make additions/corrections or give it a +1.