Skip to content

Instantly share code, notes, and snippets.

@DanCouper
Created February 12, 2016 16:30
Show Gist options
  • Save DanCouper/562983d45d28173219e9 to your computer and use it in GitHub Desktop.
Save DanCouper/562983d45d28173219e9 to your computer and use it in GitHub Desktop.
Upgrade Rails 4 to Rails 5

So's I don't forget anything

rails new app_name -db mysql

Then uncomment the edge Rails line in the Gemfile:

gem 'rails', github: 'rails/rails'

and bundle update - just bundleing will fail due to unmet dependencies. Now, rails -v should return something like Rails 5.0.0.beta2.

Run

rake rails:update

This will prompt to overwrite each config file it finds that needs overwriting. I'm doing a clean install, so, yes to everything.

Now, supposedly HAML is default and ES6 is all taken care of, but I'm having issues. So to the Gemfile, add

gem 'babel-transpiler'
gem 'haml-rails'

And all is good it seems. Run rake haml:erb2haml and dump the erb layout. The haml-rails generator command seems to be currently busted for R5 v0v

Rename application.css to application.sass

mkdir app/assets/config && touch app/assets/config/manifest.js to add the new assets manifest. Not sure of current status, whether it'll go to a YAML file once Sprockets settles, but it's tested & works if going down that route. In the manifest, add something like:

// JS and CSS bundles
//= link application.js
//= link application.css

// Images so that views can link to them
//= link_tree ../images .svg
//= link_tree ../images .png

Good to go, really. rails s and open localhost:3000 to check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment