Ruby rails 页面跳转(render和redirect_to)

Ruby代码  收藏代码
1. render :action => "long_goal", :layout => "spectacular"   
2. render :partial => "person", :locals => { :name => "david" }    
3. render :template => "weblog/show", :locals => {:customer => Customer.new}    
4. render :file => "c:/path/to/some/template.erb", :layout => true, :status => 404    
5. render :text => "Hi there!", :layout => "special"   
6. render :text => proc { |response, output| output.write("Hello from code!") }    
7. render ml => {:name => "David"}.to_xml    
8. render :json => {:name => "David"}.to_json, :callback => 'show'   
9. render :inline => "<%= 'hello ' + name %>", :locals => { :name => "david" }    
10. render :js => "alert('hello')"   
 
render ml => post.to_xml, :status => :created, :location => post_url(post)   


render(:text => string)
render(:inline => string, [:type => "rhtml"|"rxml"])
render(:action => action_name)
render(:file => path, [:use_full_path => true|false])
render(:template => name)
render(:partial => name)
render(:nothing=>true)
render()

第1行:直接渲染出文本
第2行:把传入的string渲染成模板(rhtml或者rxml)
第3行:直接调用某个action的模板,相当于forward到一个view
第4行:使用某个模板文件render, 当use_full_path参数为true时可以传入相对路径
第5行:使用模板名render,e.x.: render(:template => "blog/short_list")
第6行:以局部模板渲染
第7行:什么也不输出,包括layout
第8行:默认的的render, 相当于render(:action => self)


http://samyulong.iteye.com/blog/638142

你可能感兴趣的:(redirect)