I am using nifty layout from Ryan Bates and that includes Layout helper with following code.
in my application.html.erb
<%= stylesheet_link_tag "application", :cache => true %>
<%= javascript_include_tag :defaults, :cache => true %>
<%= yield(:head) %>
Then in the helper layout_helper.rb
def stylesheet(*args)
content_for(:head) { stylesheet_link_tag(*args) }
end
def javascript(*args)
content_for(:head) { javascript_include_tag(*args) }
end
using this in my application i can add css and javascript from any page simply by calling
<% javascript "what_ever" %>
<% stylesheet "what_ever" %>
but the problem i am facing is that these extra css or js files do not get the :cache => true and thus will not be cached.
Is there a way to resolve this?
Basically I want to have small small css files for each page and then serve one big file when it is called.
Did some digging on the net about this.
There are pros and cons for doing the small small files. So the jury is still out.
One site said the small small files help readability so better to use them but then use some programming language to combine all the css files and server them as one.
the benifit of this is that you can still develop the way you prefer but the user only needs to download the file once and does not have to make the calls for each new file.
Taking this approach, the best solution will be to divide each file and match it to the model name. The application.css contains css common to all pages, where as the modelname.css file contains items specific to that model.
then in application.html.erb, you make the call as such.
This will combine all the css files and serve them as one.