Skip to content

Instantly share code, notes, and snippets.

@ilake
Created May 18, 2014 02:38
Show Gist options
  • Save ilake/56bccd4595821177eae8 to your computer and use it in GitHub Desktop.
Save ilake/56bccd4595821177eae8 to your computer and use it in GitHub Desktop.
# app/views/layouts/application.html.erb
<%= render_stylesheets content_for(:stylesheets) %>
# app/helpers/layout_helper.rb
def render_stylesheets(tag_html = nil)
html = []
if tag_html.present?
html << tag_html
else
html << stylesheet_link_tag('application', :media => 'all')
html << stylesheet_link_tag(namespace, :media => 'all')
end
html.join("\n").html_safe
end
def namespace
controller_path.split('/').first
end
# for special need
<% content_for :stylesheets do %>
<%= stylesheet_link_tag 'application' %>
<%= stylesheet_link_tag 'contact_recordings' %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment