Lately I have to precompile my assets to see my css changes in my development environment. I don't know why this, the environment setting config.assets.debug is still set to true. I find this rather annoying, I believe I didn't have to run precompile after every change before. How do I make rails compile on page load again?
I'm running Rails 3.1.3. I don't know what other info to provide, please let me know what you need to know to solve this.
Try completely removing your compiled assets and it should reset to the default development behavior. Otherwise, Rails will keep trying to load your precompiled public/assets/ files before loading the stuff under app/assets/:
rake assets:clean
Related
Stack
Ruby 1.9.3
Rails 3.2.12
Issue
We have precompilation issues with our application.
We're trying to remove config.server_static_files = true and config.assets.compile = true from our production configs, but are constantly missing assets whenever we precompiled. Even though these assets live in app/assets, while other files in the same directory are seen and compiled.
Ex:
app/assets/stylesheets/application.css
app/assets/stylesheets/some_slider_lib.css
app/assets/stylesheets/bootstrap.min.css
After precompiling
public/assets/application-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.css
public/assets/some_slider_lib-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.css
And the manifest.yml is also missing the bootstrap file among other assets.
Same thing with our vendor folder.
Attempts
The following is the only way that I've managed to precompiles everything.
config.assets.precompile += ["*.css", "*.scss", "*.js", "*.coffee"]
However, this feels like overkill. I thought all files within the asset pipeline would be compiled. Is this not what is suppose to happen?
Also tried rake assets:precompile --trace, but this was unhelpful.
If anyone could provide a little guidance, suggestions or more it would be deeply appreciated.
Thanks!
rails beginner here
I am trying to set an app to production but having big issues with the asset pipeline. Under development every asset is generated under /assets/blabla.extension
However, I am running nginx and when running rake assets:precompile it creates assets under /public/assets as it should. But when I visit my app it generates urls like /application.css and not /assets/application-digestq12343.css as it should.
I think there is an easy fix to this problem.. but I cannot find it. Please help me!
Update:
From the documentation I read that Sprockets "default" is /assets but it certainly isn't in my application. I use the latest version of rails. Can the documentation be outdated?
http://edgeguides.rubyonrails.org/asset_pipeline.html
Even if I add config.assets.prefix = "/assets" to my production it would still mean that I would not load the assets since the digest would be missing.
I believe this is the same problem I was experiencing. Instead of using url()in your css (or scss), use asset-data-url() and add config.assets.enabled = true to your application config file. Then, rake assets:precompile before you push.
I feel like I have exhausted my resources trying to figure this out. I have yet to run into this error with a heroku/rails app before and am simply puzzled as to why my js/css isnt being compiled/uploaded to Heroku.
As stated in the heroku docs your options are to:
1. Compiling assets locally.
2. Compiling assets during slug compilation.
I tried the first option: ran RAILS_ENV=production bundle exec rake assets:precompile, added public/assets and saw the "Detected manifest.yml, assuming assets were compiled locally" line when deploying. No CSS.
I tried the second option (clean git checkout before assets:precompile). Added the 'config.assets.initialize_on_precompile = false' line as suggested for rails 3.x apps. And instead of seeing the expected:
Compiled jquery.js
Compiled jquery_ujs.js
Compiled application.js
Compiled application.css
etc etc
I get 'DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins!' warnings. yet that folder is completely empty
Looked into this warning with no sign of it being the root cause for this. Feels like I'm going in circles so I am hoping someone has insight. Thanks in advance!
Heroku docs suggests that add 'rails_12factor' gem to gemfile. Precompling assets before pushing to heroku is not required. And you also must use Heroku's cedar stack only.
Using Rails 3.2.2 and ruby 1.9.2 and I am not able to serve assets in production. We are running on apache. I've read some documentation and set :
config.serve_static_assets = true
config.assets.compile = true
in production.rb, and it doesn't seem to work. What else can I try? Or how can I get some debug info on where it IS looking.
Also, I went back to development, and went into assets/images and deleted .png files in order to intentionally break things in the development environment, but it didn't work, the images still show up. There must be some pre-compiling of assets, but where do they get stored, and how would I clear that? thanks
Usually, if you have Apache in front of your rails server, you would not want your application to compile assets in production. You probably want to pre-compile assets and have Apache serve them.
Compiled assets are stored in public/assets by default.
How all this comes together depends on the particulars of your configuration, which you have not shared. I would recommend reading the rails guides on the asset pipeline:
http://guides.rubyonrails.org/asset_pipeline.html
and in particular:
http://guides.rubyonrails.org/asset_pipeline.html#in-production
It heven has some examples of how to configure Apache.
In config/application.rb:
config.assets.enabled = true
I am new to rails and using version 3.1.0 and trying to deploy to heroku. I have a very simple application that i have managed to get up and running on heroku after working my way through several issues. I used the command
bundle exec rake assets:precompile
to get heroku to load the assets for the application (i read that heroku requires this for version 3.1.0). The problem is that when i try to run the application, the server gives the error
ActionController::RoutingError (No route matches [GET] "/assets/all.js"):
i have all of the required javascript files in public/javscripts but i cannot find any version of all.js in the assets directory. I have included
config.assets.precompile << '*.js'
in config/application.rb but to no avail.
I was wondering if someone could tell me how I get the precompile to create all.js in the assets directory or if I am completely off track here. i was under the impression that the precompile function compiled all of the javascript files into a single optimized file.
Also, if anyone has any good links for a beginner to understand how the precompile functionality works in rails I would be very appreciative.
Thanks in advance.
The best guide is the official rails guide. There is also the Railscast about it.
In a nutshell your Javascript files go in app/assets/javascript from where the precompile task will process them and put then in the public/assets directory. You should not have to change the precompile config option if the follow the defaults. Don't forget to the use the correct helpers to reference your files.
Read the resources above, and if you are converting an existing app watch the Railscast and follow the last section of the guide - these should point you in the right direction.