Once I've done bundle exec rake assets:precompile RAILS_ENV=production
It seems that it created something like application-e24jrjf834jg93bwuk13uy5gfd1y24f.css
Then when I access to the page, that is called from my app.
In development mode, I could add changes to just to css file and it applied.
In production mode, can I still add little changes to css?
If possible, how?
If you have set config.assets.initialize_on_precompile to true in your production.rb file then all you need to do is restart your server. Otherwise just delete the precompiled assets by running bundle exec rake assets:clean and precompile assets again bundle exec rake assets:precompile RAILS_ENV=production.
Related
I'm using Rails 5.0
Since I've done this command-line : ENV=production rake assets:precompile
when i change CSS I can see them in local instantly.
I have to kill the server, do this command-line again (ENV=production rake assets:precompile) in order to see the change I made.
Thaks for your help.
Rails requires you to pre-compile assets (css,js,etc) in production after you change anything in assets. However in development assets are compiled live by default.
If you want to compile assets live in production (Not Recommended):
then change config.assets.compile=false in config/environments/production.rb to:
config.assets.compile = true
That is Rails should recompile the assets when it detects that a new version of the source assets is there.
On production, you usually want to set it to false and handle asset compilation during deployment. For this, you have to run
RAILS_ENV=production bin/rails assets:precompile
Usually, if you deploy using Capistrano, it takes care of that.
Note: In rails 4 or earlier it was RAILS_ENV=production bin/rake assets:precompile but in Rails 5.x rake is merged into rails so you must use RAILS_ENV=production bin/rails assets:precompile.
In config/environments/development.rb,
I had config.assets.debug set to false instead of true.
i am new in ruby on rails, i have done some modification in assets file ( like add a new image file default2.png,some style file has be changed and some javascript file also changed).
I have uploaded all file on the server in assets folder then tried to precompile all assets with the help of following command rake assets:precompile and also tried rake assets:precompile RAILS_ENV= production
after that css was not working properly check box is not visible, some images are not displaying in page.
we try to rollback the precompile file using these steps
rm -fr public/assets
rake assets:clean
again we tried the rake assets:precompile and rake assets:precompile RAILS_ENV= production.
Problem is not resolved, i had tried with below links
database configuration does not specify adapter
Rollback rake assets:precompile
rails 4 asset pipeline vendor assets images are not being precompiled
then got error
**config.eager_load is set to nil. Please update your config/environments/*.rb fil es accordingly:
development - set it to false
test - set it to false (unless you use a tool that preloads your test enviro nment)
production - set it to true
rake aborted!
ActiveRecord::AdapterNotSpecified: '' database is not configured. Available: ["d efault", "development", "staging", "production"]
**
I was doing some mistake, if you want to add/edit new images, JavaScript and scss file in you are assets folders. you got same error then you have to do some changes...
change you java script file extension like: main.js to main.js.rb
change you scss style file extension
like: custom_style.scss to custom_style.scss.rb
compile below command
rake assets:precompile and rake assets:precompile RAILS_ENV= production
When I change a javascript file in Rails,and refresh the page,but not change.
why? I even restart the server.but still not work.
this situation caused just when I execute the command:
RAILS_ENV=production bundle exec rake assets:precompile
Add this to /config/environment/development.rb and this will work in DEV mode, for production mode you should pre-compile assets and turn off this setting.
So only for DEV mode
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
When pushing a Rails 3.2.11 app to heroku, running rake assets:precompile or RAILS_ENV=production rake assets:precompile doesn't seem to make assets available - it doesn't matter if I run this rake task locally or not.
The only solution is to set config.assets.compile = true in production.rb which seems to make the app super slow in production.
I haven't had this issue with other applications.
How do I diagnose what the deal is?
When you run this task locally, make sure that you've commited newly created files.
I've updated my Rails 3.2 app to 4.0 version and have stumbled upon one problem.
When I run the site with config.assets.compile = false option it doesn't load any assets. I've tried rake assets:precompile and it compiles assets at public/assets, but site doesn't load any of those. I've got application.js and application.css included in my layout, but when I check the source of the page, it's said that they are not found.
When I run the site with config.assets.compile = true everything works perfectly, but I've read that turning this off will result in greater performance, so I need to get it work.
Thanks in advance.
UPD: I've found that if I'm using this command RAILS_ENV=production bundle exec rake assets:precompile everything works. The question is why the rake assets:precompile command doesn't working?
UPD2: For those, who have the same issue, here's the explanation.
Regular rake assets:precompile compiles assets for application that runs in development mode. Specifying RAILS_ENV=production part in the beginning makes the command to compile assets for production mode, the bundle exec part is not required. So the final command looks like this: RAILS_ENV=production rake assets:precompile. Maybe it was obvious, but it took me a while to understand. Thanks.