Domanda

I have developed a new requirement for my client, I had added some css rule to an existing style-sheet file and these changes were reflecting on my local machine during development. But when I moved the changes to an staging server and restarted nginx all my functionalites are working but my css rules are not getting applied, when I checked the firebug console that particular file is getting included but my new css rules are not in there, should I pre-compile my css style-sheets if so how to do it in rails 2.3.x ...?

Thanks in advance.

È stato utile?

Soluzione

Rails 2.3 does not have asset pipeline. So there is no need to precompile assets. Your assets should already be located in the Rails.root/public/stylesheets folder

Anything in Rails.root/public/ folder is served by the web server directly and it does not involve rails.

Your problem is most likely some sort of caching. You can try fetching the stylesheet directly using its URL like this

http://server.domain/stylesheets/mystyles.css

and see if your changes are reflected.

You can also check your Firebug -> Net tab to see if the style sheet is being downloaded from the server (http return code: 200 OK) or it is being picked up from the cache (http return code: 304 Not Modified)

There are ways to handle this type of issues, which rails 3.1 asset pipeline incorporates.

  1. Using a different file name when content changes
  2. Using the ETag header
  3. Appending a unique hash (calculated using timestamp of the file) as a query string. For example http://domain/style.css?djfhsfhkkjdsfh where djfhsfhkkjdsfh will change every time style.css is modified.

are couple of commonly used tricks.

If you are keen on using asset pipeline with rails 2.3 you have options such as Jammit

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top