768x90 Getting Online Shouldn't be Tough- $7.49 .com Domains at Go Daddy

Types of Render in Rails

There's many render types that we can use for our view. Rails Render is a strong method that helps you to render your web pages. It comes with many flavors including:

  • Render Action : render an action in the current controller, you can specify if you want layout printed or not.

render :action => "show_home_page", :layout=> false

.

  • Render partial: it renders part of your web page.

render :partial => "left_menu"

.

  • Render template: render a page, the file path is relative to your application.

render :template=> "templates"

.

  • Render file: absolute path is needed

render :file => "#{RAILS_ROOT}/public/file.html"

.

  • Render text

render :text => "You can put any text here"

.

  • Render Json

render :json => {:name => "Teapoci"}.to_json

.


I hope the information above can be useful for you. Thank You.


.

No Response to "Types of Render in Rails"

 
powered by Blogger