开发者

Is it possible to not yield from a certain page?

开发者 https://www.devze.com 2023-04-01 18:45 出处:网络
Trying to have a p开发者_开发百科age which will not take everything from layouts/application.html.erb, Is it possible?In your controller:

Trying to have a p开发者_开发百科age which will not take everything from layouts/application.html.erb, Is it possible?


In your controller:

def my_action
  render :layout => false
end


The following will display your content unless you are on a specific page:

yield(:something) unless controller_name == 'mycontroller' and action_name == 'myaction'

The following will output header and includes unless you are on a specific page:

if controller_name == 'mycontroller' and action_name == 'myaction'
  javascript_include_tag :defaults
  javascript_include_tag 'anotherscript.js'
  yield(:head)
end


Calling render :action => "foo", :layout => false in your controller will skip your layout entirely.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号