I run a web server at rails.The pages managed by registered users can change font size and color using the form, but the changes are not reflected in real time.
CSS updates are reflected only after deployment or server restart.If a user enters without such a reboot, how can it be reflected?
For the time being, we are running rakeassets:precompile in the background, so the CSS with the new fingerprint is created under public/assets.However, when I checked the web browser, the new style sheet is not available. Why?
ruby-on-rails ruby
I don't know exactly what's going on with the program, so I'll talk to you as much as I think it's common.
If the user wants to change the CSS and reflect it immediately, it may be difficult to use the associates pipeline.
However, the precompilation option is config.assets.compile
, and if you set it to true
, "live compilation" is written in the rails guide, so you may be able to set it up well.
However, even if you say "live", you still need to reload the page.
config.assets.compile is a boolean that can be used to turn on live Sprockets compilation in production.
(Quoted from Rails Guide)
Another way to do this is to store the contents of the CSS specified by the user in a DB, etc., and write the contents on the style tag of the page.
There is a disadvantage of not being able to cache the CSS in the browser, but I think it is certain that it will not be affected by the results of the precompilation of the above assembets.
If you use javascript, I think you can save the contents of the changed CSS by using ajax while reflecting the changes in real time.
© 2024 OneMinuteCode. All rights reserved.