Providing default content for section in layout(rails 3 .erb)
Is it possi开发者_如何学Pythonble to provide default content for section in layout if it is not overridden in view?
if you are using, say a title tag in your head section of your application.html.erb layout file, you could do something as simple as <%= @title || "Some Default App Content" %>
Using this same approach, you can use it for content_for and other helper methods.
Now, Rails have content_for?
method for it: http://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#method-i-content_for
精彩评论