Rails 5 requires Ruby 2.2.2 or newer. (2.2.4 or 2.3.0)
reduce memory usage by taking advantage of GC
gem update --system
ApplicationRecord && ApplicationJob
ApplicationRecord
ApplicationJob
ApplicationMailer
ApplicationController
# app/models/application_record.rb
class ApplicationRecord < ActiveRecord ::Base
self . abstract_class = true
end
# app/jobs/application_job.rb
class ApplicationJob < ActiveJob ::Base
end
rails db:migrate
rails styleguide:build
deprecated :nothing option for render()
head :ok
head :not_found
head :unauthorized
head :internal_server_error
RedirectBackError
redirect_back(fallback_location: root_path)
rails#22506
required fallback_location argument
# app/controllers/application_controller.rb
def redirect_back ( fallback_location : request . referer || root_path , **args )
super ( fallback_location : fallback_location , **args )
end
params not inherited from hash
rails#20868
params.to_h
& params.to_unsafe_h
DEPRECATION WARNING (deprecated in rails 5.1)
skip_before_filter
-> skip_before_action
before_filter
-> before_action
get :show , id : funding . id , format : :json # before
get :show , params : { id : funding . id , format : :json } # now
rails db:migrate
add_index
-> t.index
Funding . where ( status : 0 ) . or ( Funding . where ( role : 0 ) ) . to_sql
SELECT \" fundings\" .* FROM \" fundings\" WHERE (\" fundings\" .\" status\" = 0 OR \" fundings\" .\" role\" = 0 )
belongs_to required by default
config . active_record . belongs_to_required_by_default = false
class UserPitch < ApplicationRecord
has_secure_token :token
end
# rails g model user_pitch token:token
create_table :user_pitches do |t |
t . string :token
t . timestamps
end
add_index :user_pitches , :token , unique : true
up = UserPitch . create
up . token
up . regenerate_token
//= link_tree ../images
//= link_directory ../javascripts .js
//= link_directory ../stylesheets .css