-
-
Save notyoyoma/6a81bc69342b0b309d6f to your computer and use it in GitHub Desktop.
This file contains 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
diff --git a/app/assets/stylesheets/products-singular.css.scss b/app/assets/stylesheets/products-singular.css.scss | |
new file mode 100644 | |
index 0000000..e69de29 | |
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb | |
index e3fd632..445478e 100755 | |
--- a/app/helpers/application_helper.rb | |
+++ b/app/helpers/application_helper.rb | |
@@ -127,4 +127,15 @@ module ApplicationHelper | |
end | |
+ def controller_assets asset_folder | |
+ if ! Dir.glob("app/assets/#{asset_folder}/#{params[:controller]}-singular.*").empty? | |
+ logger.info "ASSET: Controller specific #{asset_folder.singularize} / #{params[:controller]} found." | |
+ "#{params[:controller]}-singular" | |
+ else | |
+ logger.info "ASSET: Controller specific #{asset_folder.singularize} / #{params[:controller]} not found." | |
+ nil | |
+ end | |
+ end | |
+ | |
+ | |
end | |
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb | |
index 5fb35fb..b356f87 100755 | |
--- a/app/views/layouts/application.html.erb | |
+++ b/app/views/layouts/application.html.erb | |
@@ -9,7 +9,7 @@ | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<meta name="p:domain_verify" content="dc802b645a0b68c38937e215079878c2"/> | |
- <%= stylesheet_link_tag "application" %> | |
+ <%= stylesheet_link_tag "application", controller_assets("stylesheets") %> | |
<!--[if gt IE 9]><!--><%= stylesheet_link_tag "css/app", :media => nil %><!--<![endif]--> | |
<!--[if IE 9]><%= stylesheet_link_tag "css/app.blessed", :media => nil %><![endif]--> | |
<!--[if lte IE 8]><%= stylesheet_link_tag "css/app-old-ie", :media => nil %><![endif]--> | |
@@ -222,7 +222,7 @@ | |
<%= javascript_include_tag "foundation/js/foundation.min" %> | |
<![endif]--> | |
-<%= javascript_include_tag "application" %> | |
+<%= javascript_include_tag "application", controller_assets("javascripts") %> | |
<script> | |
$(document).ready(function(){ | |
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb | |
new file mode 100644 | |
index 0000000..a00c22e | |
--- /dev/null | |
+++ b/config/initializers/assets.rb | |
@@ -0,0 +1,7 @@ | |
+# Note: in a development environment ApplicationController.subclasses will only return | |
+# lazy-loaded subclasses. So the dev environment will not pre-compile assets | |
+# (it shouldn't anyways) | |
+ApplicationController.subclasses.each do |controller| | |
+ controller_name = controller.name[/([^:]*)/, 0].underscore | |
+ Rails.application.config.assets.precompile += ["#{controller_name}.js", "#{controller_name}.scss"] | |
+end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment