Saturday, June 27, 2009

Rails 2.x substantials

>> New template naming syntax.
action.type.renderer
.rhtml > .html.erb
.rjs > .js.rjs
.rxml > .xml.builder
.haml > .html.haml

>> Sexy Migrations

>> rake routes
Lists all routes defined for your application

>> rake db:migrate:reset
This will drop the database and will create the database.

>> rake db:migrate:redo
rollback one migration and migrate back up. If you need to go further than one step back pass the STEP=x parameter (rake db:migrate:redo STEP=X)

>> Connection Pooling

>> Deprecations
• find(:all) not find_all
• form_for not form_tag
• pagination is gone

>> Active Record validation :allow_blank
 
validates_length_of :name, :maximum => 15, :allow_blank => true
user = User.new(:name => "")
user.valid? #=> true

>> Commercial DB's out of rails core, available as gems
 
gem install activerecord-oracle-adapter
gem install activerecord-sqlserver-adapter
gem install activerecord-firebird-adapter
gem install activerecord-frontbase-adapter
gem install activerecord-openbase-adapter
gem install activerecord-sybase-adapter

>> Partials can have their own layouts
 
<%= render :partial => 'user_info', :layout => 'boxed', :locals => {:user => @user} %>

>> Accessing helper
 
class ApplicationController < ActionController::Base
# Our many helpers that need to be available throughout the app
[:formatting, :highlighting, :i18n].each { |h| helper h } ...
end

class ApplicationController < ActionController::Base
# Make all helpers in app/helpers/**/ available
helper :all ...
end

>> Cookie based session are the new Default session store
Previously it was file based session store