Skip to content

Instantly share code, notes, and snippets.

@ihower
Created April 23, 2011 04:28
Show Gist options
  • Save ihower/938280 to your computer and use it in GitHub Desktop.
Save ihower/938280 to your computer and use it in GitHub Desktop.
Rails 3.1

Rails 3.1 overview

Railtie

Console shows SQL queries right there.

JQuery & RJS out

Asset Template Engine: SCSS, CoffeeScript

Rack::Cache

Add Rack::Cache to the default stack. Create a Rails store that delegates to the Rails cache, so by default, whatever caching layer you are using will be used for HTTP caching. Note that Rack::Cache will be used if you use #expires_in, #fresh_when or #stale with :public => true. Otherwise, the caching rules will apply to the browser only. [Yehuda Katz, Carl Lerche]

Mountable Engines

ActionPack

Http Streaming

Template Inheritance

force_ssl

automatically adds :multipart => true to the enclosing form.

ActionController::ParamsWrapper

...

ActionView

form_for method

form_for(@post, remote: true, method: :delete) instead of form_for(@post, remote: true, html: { method: :delete })

j helper

Make JavaScriptHelper#j() an alias for JavaScriptHelper#escape_javascript()

HTML5 data-* attributes

tag("div", :data => {:name => 'Stephen', :city_state => %w(Chicago IL)}) =>

file_field

ActiveRecord&ActionModel

Identity Map

SecurePassword

new mass assignment capabilities

attr_accessible :title, :published_at, :as => :admin Post.new(params[:post], :as => :admin)

assign_attributes() with similar API was also added and attributes=(params, guard) was deprecated.

update_column

update_column method on ActiveRecord. This new method updates a given attribute on an object, skipping validations and callbacks.

migration

class MyMigration < ActiveRecord::Migration def change create_table(:horses) do t.column :content, :text t.column :remind_at, :datetime end end end

Migrations should use instance methods rather than class methods:

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