#265 Rails 3.1 Overview
May 09, 2011 | 13 minutes | Rails 3.1
This is the first episode in a series covering Rails 3.1. Here I show how to install the beta and show some of the new features.
Resources
Note: The Active Record Identity Map feature is now disabled by default and is currently not recommended due to problems with associations. It looks like it will not make it into 3.1 final.
bash
rvm 1.9.2@railspre --create
gem install rails --pre
rails new todo
cd todo
bundle
rails g scaffold project name:string
rake db:migrate
rake test
rvm 1.9.2@railspre --create gem install rails --pre rails new todo cd todo bundle rails g scaffold project name:string rake db:migrate rake test
rails console
p = Project.create!(:name => "Yardwork")
p2 = Project.find(1)
p.object_id == p2.object_id
p = Project.create!(:name => "Yardwork") p2 = Project.find(1) p.object_id == p2.object_id
projects.js
alert "Hello world!"
alert "Hello world!"
models/project.rb
has_many :tasks
has_many :assigments, :through => :tasks
has_many :users, :through => :assignments
attr_accessible :name, :as => :admin
has_many :tasks has_many :assigments, :through => :tasks has_many :users, :through => :assignments attr_accessible :name, :as => :admin
projects_controller.rb
@project.update_attributes(params[:project], :as => :admin)
@project.update_attributes(params[:project], :as => :admin)
rhtml
<%= link_to "Edit", edit_project_url(@project, :subdomain => "foo") %>
<%= link_to "Edit", edit_project_url(@project, :subdomain => "foo") %>
