Rails 4 Diff
Rails 4 Diff
RAILS
MASTERCLASS
by owningrails.com
Strong Parameters
CONTROLLERS
Routing
concern :commentable do
resources :comments
end
params.require(:post).
permit(:title, :body)
Includes routes inside concern
Declarative ETags
class InvoicesController < ApplicationController
etag { current_user.try :id }
Live Streaming
def show
@invoice = Invoice.find(params[:id])
fresh_when @invoice
end
end
Tests
test/units
test/units/helpers
test/functional
test/functional
test/integration
MODELS
Migrations
reversible do |dir|
change_table :products do |t|
dir.up
{ t.change :price, :string }
dir.down { t.change :price, :integer }
end
end
class Person
include ActiveModel::Model
attr_accessor :name
Adds validation & allow to
end
use in controllers & views.
PostgreSQL only
Query
Scopes
Ticket.all
Ticket.my_scope.load
Ticket.my_scope.to_a
Ticket.none
VIEWS
ActiveModel::Model
revert SomePreviousMigration
t.integer :int_array,
array: true
t.string :string_array, array: true
test/models
test/helpers
test/controllers
test/mailers
test/acceptance
Turbolinks
<link ... type="text/css" data-turbolinks-track>
<script ...
data-turbolinks-eval=false>
<a ...
data-no-turbolink>
Tired of trying to keep up with the latest changes in Rails? Join the Owning Rails Masterclass and master Rails once and for all!
owningrails.com
Coded Inc.