whats new in rails2
程序员文章站
2022-07-14 14:34:33
...
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
上一篇: scf跑起来
下一篇: whats new in rails2
推荐阅读
-
重写、隐藏基类(new, override)的方法
-
PHP的new static和new self的区别与使用
-
react中图片校验码实现以及new Buffer()使用方法
-
new Date,Date.parse()传值
-
C#中new和override的区别个人总结
-
javascript中new关键字详解
-
PHP中new static()与new self()的区别异同分析
-
You have new mail in /var/spool/mail/root 解决烦琐提示的方法
-
深入理解C#中new、override、virtual关键字的区别
-
IOS开发之关于alloc 、init和new学习讲解