Upgrade to Pro — share decks privately, control downloads, hide ads and more …

What's new in Rails 4.1

What's new in Rails 4.1

Lauro Caetano

January 28, 2014
Tweet

More Decks by Lauro Caetano

Other Decks in Programming

Transcript

  1. ! # bundle exec spec spec/models/book_spec.rb! # 15.30s user 1.63s

    system 99% cpu 16.976 total! 12 examples, 0 failures ! ! # bin/spring rspec spec/models/book_spec.rb! # 1.01s user 0.10s system 17% cpu 6.453 total! 12 examples, 0 failures
  2. class ApplicationController < ActionController::Base! def some_action! respond_to do |format|! format.html

    do |html|! html.tablet ! html.phone! end! end! end! end! ! # in app/views/projects/show.html+tablet.erb! # in app/views/projects/show.html+phone.erb
  3. class ApplicationController < ActionController::Base! def some_action! respond_to do |format|! format.js

    { render "trash" }! format.html.phone { redirect_to progress_path }! format.html.none { render "trash" }! end! end ! end
  4. class NotifierPreview < ActionMailer::Preview! def welcome! Notifier.welcome(User.first)! end ! end!

    # => http://localhost:3000/rails/mailers! # in /test/mailers/previews/notifier_preview.rb
  5. class Conversation < ActiveRecord::Base! enum status: [:active, :archived]! end! !

    conversation.archived!! conversation.active?! # => false! conversation.status! # => "archived"! ! Conversation.archived! # => Relation for all archived Conversations!
  6. class Conversation < ActiveRecord::Base! enum status: { active: 0, archived:

    1 }! end! ! conversation.archived!! conversation.active?! # => false! conversation.status! # => "archived"! ! Conversation.archived ! # => Relation for all archived Conversations!