else
respond_to do |format|
format.html { render "tabelle/show" }
end
end
I want to render the page ...with only the code in that page....not add <head>
...layout and <body>
field in ruby on rails. I only want to show the result of code in the page tabelle/show.html.haml
你可以这样做:
format.html { render "tabelle/show", :layout => false }
add
:layout => false
Example:
render "tabelle/show", :layout => false
Controller:
layout false, only: [:method_name]
this is very useful when you using render_to_string
Rails is smart enough to know which view template to use based on the Controller Action you're on.
For example, if you're on the show
action of the TabellesController
you wouldn't need to specify render "tabelle/show"
in your Controller Action because Rails will already assume that and will automatically try to render the file in app/views/tabelles/show.html.erb
.
So if you're sticking with all of those defaults then you can just use the following to render without the typical layout template:
def show
# Other stuff in your Controller Action.
render layout: false
end
This will render app/views/tabelles/show.html.erb
but without the layout template automatically.
Noice.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.