Created
February 2, 2012 20:00
-
-
Save luckydev/1725430 to your computer and use it in GitHub Desktop.
Rendering views in rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#all these will render guests/new.html.erb template | |
#calling from an action in ActivitiesConctoller, for example. | |
render "guests/new" | |
render "guests/new.html.erb" | |
render :template => "guests/new" | |
render :template => "guests/new.html.erb" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#all these will render "orders/edit.html.erb" | |
#calling from OrdersController for example | |
render "edit" | |
render "edit.html.erb" | |
render :edit | |
render :action => :edit | |
render :action => "edit.html.erb" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#all these will render app/own_views/special_profile.html.erb | |
#give full path to the template, from the / (root) path. | |
render "/Users/Anand/Web/sample_app/app/own_views/special_profile.html.erb" | |
render :file => "/Users/Anand/Web/sample_app/app/own_views/special_profile.html.erb" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#just call `render` or do nothing. | |
#Rails will render the action's template auto-magically | |
class UsersController | |
def new | |
#will render users/new.html.erb | |
end | |
def edit | |
render | |
#will render users/edit.html.erb | |
end | |
end |
Author
luckydev
commented
Feb 6, 2012
rocks in every way
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment