user984621
user984621

Reputation: 48511

Rails 3.1 - how to update CSS styles

I have an app in Rails 3.1 and when I whatever change in the application.css, so these changes are not applied on the page.

Is here something else than in Rails 3?

Upvotes: 1

Views: 2795

Answers (3)

mikewilliamson
mikewilliamson

Reputation: 24803

I just stumbled across this too.

A little poking around reveals that when you run rake assets:precompile, as part of its process it writes an application.css file into your public folder.

It seems that it is the application.css in the public directory that is being served on subsequent requests instead of the ones in the asset folder that you are working on.

If you delete the application.css file in the public directory you should be able to see you updates to the CSS when you reload the page.

I hope that helps.

Upvotes: 1

Simpleton
Simpleton

Reputation: 6415

From Rails 3.1, compiled assets are written to the location specified in config.assets.prefix. You must use the below task either during deployment or on localhost, if you do not have write access to your production filesystem:

bundle exec rake assets:precompile

You can configure your app for faster asset precompiles. To do this, you can partially load your application by setting config.assets.initialize_on_precompile to be set to false in your config/application.rb. However, you should note that in this case, templates cannot see application objects or methods. Heroku requires this to be set to false so if you're running your app there, you should probably do this.

Upvotes: 3

hkairi
hkairi

Reputation: 385

Are you running the application in production mode? if so you will need to precompile the assests ( rake assests:precompile ) and to restart your webserver.

Upvotes: 2

Related Questions