aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikachu.com>2012-08-06 16:22:23 -0400
committerPrem Sichanugrist <s@sikachu.com>2012-08-06 16:38:52 -0400
commit8e2a05b33da1cd27d18a82168b49ba642122fbdb (patch)
tree54ef512f02d6496ecb595eac38379a3e74d311f7 /actionpack/lib
parent0fb6bbdf7e708691ab3ed320868b7bcebfc68885 (diff)
downloadrails-8e2a05b33da1cd27d18a82168b49ba642122fbdb.tar.gz
rails-8e2a05b33da1cd27d18a82168b49ba642122fbdb.tar.bz2
rails-8e2a05b33da1cd27d18a82168b49ba642122fbdb.zip
Do not include application.js if it doesn't exists
Rails were including 'application.js' to the pack when using `javascript_include_tag :all` even there's no application.js in the public directory.
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb b/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
index d9f1f88ade..7449f93671 100644
--- a/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
+++ b/actionpack/lib/action_view/helpers/asset_tag_helpers/javascript_tag_helpers.rb
@@ -27,7 +27,8 @@ module ActionView
def expand_sources(sources, recursive = false)
if sources.include?(:all)
- all_asset_files = (collect_asset_files(custom_dir, ('**' if recursive), "*.#{extension}") - ['application']) << 'application'
+ all_asset_files = (collect_asset_files(custom_dir, ('**' if recursive), "*.#{extension}") - ['application'])
+ add_application_js(all_asset_files, sources)
((determine_source(:defaults, expansions).dup & all_asset_files) + all_asset_files).uniq
else
expanded_sources = sources.inject([]) do |list, source|
@@ -40,7 +41,7 @@ module ActionView
end
def add_application_js(expanded_sources, sources)
- if sources.include?(:defaults) && File.exist?(File.join(custom_dir, "application.#{extension}"))
+ if (sources.include?(:defaults) || sources.include?(:all)) && File.exist?(File.join(custom_dir, "application.#{extension}"))
expanded_sources.delete('application')
expanded_sources << "application"
end
@@ -101,8 +102,8 @@ module ActionView
#
# config.action_view.javascript_expansions[:defaults] = %w(foo.js bar.js)
#
- # When using <tt>:defaults</tt>, if an <tt>application.js</tt> file exists in
- # <tt>public/javascripts</tt> it will be included as well at the end.
+ # When using <tt>:defaults</tt> or <tt>:all</tt>, if an <tt>application.js</tt> file exists
+ # in <tt>public/javascripts</tt> it will be included as well at the end.
#
# You can modify the HTML attributes of the script tag by passing a hash as the
# last argument.
@@ -129,7 +130,7 @@ module ActionView
# # <script type="text/javascript" src="/javascripts/rails.js?1284139606"></script>
# # <script type="text/javascript" src="/javascripts/application.js?1284139606"></script>
#
- # * = The application.js file is only referenced if it exists
+ # Note: The application.js file is only referenced if it exists
#
# You can also include all JavaScripts in the +javascripts+ directory using <tt>:all</tt> as the source:
#