So, here is the output code and what’s displayed. As you can see, I
simplified the helper calls and am able to call multiple stylesheets and
javascripts and am able to feed image tags with options.
application.html.erb
<%= css_theme('default.css','scaffold.css') %>
<%= js_theme('default.js','testtwo.js') %>
<%= link_to img_theme('logo.jpg', :alt => 'Back to the homepage'), root_url %>
application_helper.rb
def js_theme(*files)
file_array = [*files]
js_array = []
file_array.each do |row|
js_array += current_theme_path('js', row.to_s).to_a
end
javascript_include_tag(:defaults, js_array)
end
def css_theme(*files)
This file has been truncated. show original
site.html
<link href="/themes/default/stylesheets/default.css?1263252884" media="screen" rel="stylesheet" type="text/css" />
<link href="/themes/default/stylesheets/scaffold.css?1263252968" media="screen" rel="stylesheet" type="text/css" />
<script src="/javascripts/prototype.js" type="text/javascript"></script>
<script src="/javascripts/effects.js?1263578224" type="text/javascript"></script>
<script src="/javascripts/dragdrop.js?1263578224" type="text/javascript"></script>
<script src="/javascripts/controls.js?1263578224" type="text/javascript"></script>
<script src="/javascripts/swfobject.js?1263578224" type="text/javascript"></script>
<script src="/themes/default/javascripts/default.js?1263578286" type="text/javascript"></script>
<script src="/themes/default/javascripts/testtwo.js?1263587716" type="text/javascript"></script>
<script src="/javascripts/application.js?1263578223" type="text/javascript"></script>
This file has been truncated. show original
application.html.erb gives you an idea of what’s being placed in the
head and in the body tags as an example.
application_helper.rb contains the helper methods being called.
display.html shows you what is output in a browser and as you can see
the assets are being managed properly.
another way is reusing code as in
given,
by using the layout helpers down to each action by extending the
default includes
given in your layout(s)