2016年1月6日水曜日

Rails5 Update work of rails v5.0.0 beta 1 from rails4. Page 1

  • Published Date:Jun. 6, 2016

Environment


  • rails 4.2.4, rails 4.2.5 → rails5.0.0beta1
  • ruby 2.2.3
  • rbenv rbenv 0.4.0-183-gc18a3f9

Article Summary


Rails 5.0.0Beta1 Released. I think Rails 5 will probably be released in spring of 2015.
But, if you change from rails 4 to rails 5 in Gemfile, your app would not operate correctly.

Currently, I'm doing much trial and error. At same time, I understood a lot of things. so, I write what I understood.

Japanese

Spring is unsupported


On Rails 5.0.0Beta1, Spring gem is not available. So, if your app uses spring, you should remove spring gem.
if you use Bundler, you should do the follow.

terminal

vi Gemfile

// comment out
#gem 'spring'
#gem 'spring-commands-rspec'

rbenv exec bundle exec gem uninstall spring
rbenv exec bundle exec gem uninstall spring-commands-rspec

kaminari is unsupported


On Rails 5.0.0Beta1, kaminari gem is not available. it occurs ActionView::MissingTemplate.
if you want to use kaminari, you should change to latest kaminari gem.
if you use Bundler, you should change the Gemfile.

Before

{project_folder}/Gemfile

gem 'kaminari'

After

{project_folder}/Gemfile

gem 'kaminari', github: 'amatsuda/kaminari'

After you modified Gemfile, execute bundle update.

terminal

rbenv exec bundle install

Using kaminari 1.0.0.alpha (was 0.16.3) from git://github.com/amatsuda/kaminari.git (at master)

DEPRECATION WARNING: `serve_static_files` is deprecated and will be removed in Rails 5.1.


serve_static_files became deprecated. This is from Rails 4.2, and will remove it completely on Rails 5.1.
So, you must change the following description.

Before

{project_folder}/config/environments/test.rb(development.rb and production.rb)

  # Configure static asset server for tests with Cache-Control for performance.
  config.serve_static_files  = true

After

{project_folder}/config/environments/test.rb(development.rb and production.rb)

  # Configure static asset server for tests with Cache-Control for performance.
  config.public_file_server.enabled  = true

DEPRECATION WARNING: `static_cache_control` is deprecated and will be removed in Rails 5.1.


static_cache_control became deprecated. This will be also removed completely on Rails 5.1.
So, you must change the following description.

Before

{project_folder}/config/environments/test.rb(development.rb and production.rb)

  # config.serve_static_assets = ENV['RAILS_SERVE_STATIC_FILES'].present?
  config.static_cache_control = 'public, max-age=3600'

After

{project_folder}/config/environments/test.rb(development.rb and production.rb)

  # config.serve_static_assets = ENV['RAILS_SERVE_STATIC_FILES'].present?
  config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }

DEPRECATION WARNING: before_filter is deprecated and will be removed in Rails 5.1.


before_filter became deprecated. This method is very useful, but removed completely on Rails 5.1.
So, you must change the following description.

Before

{projectfolder}/app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  before_filter :set_locale
  
  // something

end

After

{projectfolder}/app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception

  before_action :set_locale
  
  // something

DEPRECATION WARNING: use_transactional_fixtures= is deprecated and will be removed from Rails 5.0.


use_transactional_fixtures became deprecated. This is still unsupported on Rspec. So, you must not modify this.

Summary


if you think rails 5 update, it takes a lot of times.
so, you create new git branch soon, take measures.

I always think that rails major updating is difficult. But rails 5 updating is easier than rails 4 updating.
Rails has always evolved. This time is also same.

See you

Recommended Book for Rails 4 Developer


For Improving your ruby programming.


Administrating Site(createing rails)


Useful site


Japanese

0 件のコメント:

コメントを投稿