whats new in rails2

ActiveRecord

  • Post.new.from_xml ({:title => "Hello!", :body => "text"}.to_xml)
  • CSRF
  • Partial layouts
    <% render :partial => "post", :layout => "window" %>
    or with a block:
    <% render :layout => "window", :locals => { :name => "Recent" } do %>
      <% for post in @recent_posts %>
        <h2><%=h post.title %></h2>
        <!‐‐ ... ‐‐>
      <% end %>
    <% end %>
  • HTTP authentication
  • simply_helpful
    dom_class(@person) => "person"
    dom_class(Person) => "person"
    dom_class(@person, :edit) => "edit_person"
    dom_id(@person) => "person_1234"
    dom_id(Person.new) => "new_person"
     
  • url_for
    url_for(@post) works like 
    post_path(@post).
    
    url_for(Post.new) works like 
    new_post_path.
    
    Works with link_to, redirect_to, etc.
    
    render :partial => @post works like 
    render :partial => "post", :object => @post
    
    render :partial => @posts works like 
    render :partial => "post", :collection => @posts
     
  • form_for
    <% form_for @person do |f| %>
      <%= f.text_field :name %>
    <% end %>
    
    Determines form action based on the 
    record. (e.g. post_path or new_post_path)
  • Hash#except is the inverse of Hash#slice
  • Rake tasks
    rake db:create and db:create:all
    rake db:drop and db:drop:all
    rake db:reset
    rake db:rollback (defaults to STEP=1)
    rake db:version
    
    rake routes
  • Initializer hooks
    Rails load order:
    1. config/preinitializer.rb
    2. config/environment.rb
    3. config/environments/RAILS_ENV.rb
    4. config/initializers/*.rb
      

 

 

 

http://delynnberry.com/projects/userstamp/

http://svn.techno-weenie.net/projects/plugins/

http://dev.rubyonrails.org/browser/plugins

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值