my assets (i.e. css and js) in vendor folders are not showing in heroku staging environment, however, images in app/assets/images works and it also works in development environment though. I do not want to move the assets in vendors folder to the app folder because I want to keep vendor templates separate.
Below are my setup and the list of things I have tried:
app/assets/stylesheets/application.css.scss
*= require_tree .
*= require_self
*= require style.default
app/assets/stylesheets/application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require jquery-1.11.1.min
//= require jquery-migrate-1.2.1.min
//= require jquery-ui-1.10.3.min
//= require modernizr.min
//= require bootstrap.min
//= require jquery.sparkline.min
//= require toggles.min
//= require retina.min
//= require jquery.cookies
//= require custom
//= require dashboard
//= require_tree .
config/initializers/assets.rb
Rails.application.config.assets.precompile += %w( *.css *.js )
Ran the following command in terminal
RAILS_ENV=production rake assets:precompile
RAILS_ENV=staging rake assets:precompile
rake assets:precompile
heroku run rake assets:precompile
Results from pushing to Heroku using "git push staging master". Manifest file was detected as shown below.
remote: Bundle complete! 35 Gemfile dependencies, 85 gems now installed.
remote: Gems in the groups development and test were not installed.
remote: Bundled gems are installed into ./vendor/bundle.
remote: Bundle completed (1.14s)
remote: Cleaning up the bundler cache.
remote: Detected manifest file, assuming assets were compiled locally
environments/staging.rb
config.serve_static_files = true
environments/production.rb
config.serve_static_files = true
Heroku Config
RACK_ENV: staging
RAILS_ENV: staging
GemFile
group :production do
gem 'unicorn'
gem 'rails_12factor'
gem 'pg'
gem 'heroku-deflater'
end
Rails Version
Rails 4.2.0
Ruby Version
ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin13.0]
Note: "config.assets.compile = true" works, but the idea is to precompile all the assets, not to rely on compile
Many thanks for taking the effort to look at my work.
UPDATE
group :production :staging do
gem 'unicorn'
gem 'rails_12factor'
gem 'pg'
gem 'heroku-deflater'
end
adding :staging to in gemfile didnt work.
config/application.rb
config.serve_static_assets = true
adding config.serve_static_assets in application.rb file didnt work..
So I further ran the following command in the staging heroku:
Rails.application.config.assets
{:_blocks=>[#<Proc:0x007fbbb0bf1558#/app/vendor/bundle/ruby/2.1.0/gems/autoprefixer-rails-5.1.8/lib/autoprefixer-rails/railtie.rb:14>, #<Proc:0x007fbbb39ac0d8#/app/vendor/bundle/ruby/2.1.0/gems/sass-rails-5.0.3/lib/sass/rails/railtie.rb:56>], :paths=>["/app/app/assets/images", "/app/app/assets/javascripts", "/app/app/assets/stylesheets", "/app/vendor/assets/fonts", "/app/vendor/assets/javascripts", "/app/vendor/assets/stylesheets", "/app/vendor/bundle/ruby/2.1.0/gems/bootstrap_form-2.2.0/app/assets/stylesheets", "/app/vendor/bundle/ruby/2.1.0/gems/turbolinks-2.5.3/lib/assets/javascripts", "/app/vendor/bundle/ruby/2.1.0/gems/jquery-rails-4.0.3/vendor/assets/javascripts", "/app/vendor/bundle/ruby/2.1.0/gems/coffee-rails-4.1.0/lib/assets/javascripts"], :prefix=>"/assets", :manifest=>nil, :precompile=>[#<Proc:0x007fbbb1c00228#/app/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.2.4/lib/sprockets/railtie.rb:60 (lambda)>, /(?:\/|\\|\A)application\.(css|js)$/, "*.css", "*.js"], :version=>"1.0", :debug=>false, :compile=>false, :digest=>true, :js_compressor=>:uglifier, :css_compressor=>:sass}
Rails.application.config.assets.precompile
[#<Proc:0x007fbbb1c00228#/app/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.2.4/lib/sprockets/railtie.rb:60 (lambda)>, /(?:\/|\\|\A)application\.(css|js)$/, "*.css", "*.js"]
Also ran "heroku run rails c" then executed the following:
irb(main):002:0> puts helper.asset_path("style.default.css")
/assets/style.default-84d0516848a763e0b8b8b7005f7ae816.css
Used the following debugging method for heroku staging:
$ heroku run bash
$ ls public/assets
Output below
angular.min-4d194b7f4f12ed8eafec2d7a0c835904.js
angular.min-4d194b7f4f12ed8eafec2d7a0c835904.js.gz
animate.delay-0faaa57b808dee7f42f39ede364a56fb.css
animate.delay-0faaa57b808dee7f42f39ede364a56fb.css.gz
animate.min-fa7d9f43baff3065a44d391f5fb24dec.css
animate.min-fa7d9f43baff3065a44d391f5fb24dec.css.gz
application-30c5d5ea113f5d302dc72bac7a453e2c.js
application-30c5d5ea113f5d302dc72bac7a453e2c.js.gz
application-76133410c1e24aced49dbeb2178152ad.css
application-76133410c1e24aced49dbeb2178152ad.css.gz
basketcats-4984b24e5c745a825577436dcb5b1f7d.jpg
blogger-icon-5330825185af26ebf796626aab07992f.png
bootstrap-07c26bce6cfb4d4d3e91c2a7f3316ddd.js
bootstrap-07c26bce6cfb4d4d3e91c2a7f3316ddd.js.gz
bootstrap-datetimepicker.min-23b3c4525c36203db02c2000791bc8ee.js
bootstrap-datetimepicker.min-23b3c4525c36203db02c2000791bc8ee.js.gz
bootstrap-editable-c6281cc109e5208b5848e765b4d14da8.css
bootstrap-editable-c6281cc109e5208b5848e765b4d14da8.css.gz
bootstrap-editable.min-86d8ede345d06aca30530a7f95bb3931.js
bootstrap-editable.min-86d8ede345d06aca30530a7f95bb3931.js.gz
bootstrap-f2f6511fea58665b99245ff7db3724e8.css
bootstrap-f2f6511fea58665b99245ff7db3724e8.css.gz
bootstrap.min-237197a13514aaac49ee55c33a5ad363.css
bootstrap.min-237197a13514aaac49ee55c33a5ad363.css.gz
bootstrap.min-b0cd0a0791f795c4eb27679904b83f74.js
bootstrap.min-b0cd0a0791f795c4eb27679904b83f74.js.gz
bootstrap-override-2285f5091ba098ac5e5b620d7db3ca55.css
bootstrap-override-2285f5091ba098ac5e5b620d7db3ca55.css.gz
bootstrap-override-rtl-bdad9b2be471ec2aef1e04ac90377f0f.css
bootstrap-override-rtl-bdad9b2be471ec2aef1e04ac90377f0f.css.gz
bootstrap-rtl.min-b644011950d9b9fa31bc53f9705e829e.css
bootstrap-rtl.min-b644011950d9b9fa31bc53f9705e829e.css.gz
bootstrap-timepicker.min-92be9db07f554142043df94d011f0e92.js
bootstrap-timepicker.min-92be9db07f554142043df94d011f0e92.js.gz
bootstrap-timepicker.min-e317eaa00793dd79a1f8ef9fc3e792a9.css
bootstrap-timepicker.min-e317eaa00793dd79a1f8ef9fc3e792a9.css.gz
bootstrap-wizard.min-5a2783eaf5831f429126f8396dcda73e.js
bootstrap-wizard.min-5a2783eaf5831f429126f8396dcda73e.js.gz
bootstrap-wysihtml5-2024d0b1f3587a8af79c9375d11cbd96.css
bootstrap-wysihtml5-2024d0b1f3587a8af79c9375d11cbd96.css.gz
bootstrap-wysihtml5-845f80e90c6fe0c9944d78f7853f84c4.js
bootstrap-wysihtml5-845f80e90c6fe0c9944d78f7853f84c4.js.gz
business cat1-010151a22ba0940c53db4db068fbbb15.jpg
CatJira_logo1-347a04943f1922fa83c1e04cb9aa8d74.jpg
CatJira_logo-8b34a4e3a18a5ce98b6caf040eec0325.png
catplay-33ba713cd70738acbc11793b804789aa.jpg
charts-8dcf96513924266cccab40b5c3abd928.js
charts-8dcf96513924266cccab40b5c3abd928.js.gz
chosen.jquery.min-20f9114437b36992aa9d5a3236f3b2ee.js
chosen.jquery.min-20f9114437b36992aa9d5a3236f3b2ee.js.gz
city2-51820272cfac0a176203d69b5673f92c.jpg
codemirror
coffee-script-01f57d14cfd792fc3e4e41634619b898.js
coffee-script-01f57d14cfd792fc3e4e41634619b898.js.gz
colorpicker-274db192cab38eda2fe54fbe602aee81.js
colorpicker-274db192cab38eda2fe54fbe602aee81.js.gz
colorpicker-e8da384e85b77e601f62ec93d6517dc3.css
colorpicker-e8da384e85b77e601f62ec93d6517dc3.css.gz
creatives-398bec8370d485f61d0efbff7a47960c.jpg
custom-9bac754fb2b328db1aa727679a5333e0.js
custom-9bac754fb2b328db1aa727679a5333e0.js.gz
dashboard-387a6961818e57e508986d4fffaab4f6.js
dashboard-387a6961818e57e508986d4fffaab4f6.js.gz
dropzone-9e3f4db91b70bf7422487de2a3695678.css
dropzone-9e3f4db91b70bf7422487de2a3695678.css.gz
dropzone.min-64643fa97a6d52f7a63b1c17296ca35e.js
dropzone.min-64643fa97a6d52f7a63b1c17296ca35e.js.gz
errors-64e62ddc273c2f5847f30d698ca14b67.css
errors-64e62ddc273c2f5847f30d698ca14b67.css.gz
errors-fcec5b5a277ac7c20cc9f45a209a3bcd.js
errors-fcec5b5a277ac7c20cc9f45a209a3bcd.js.gz
facebook-icon-0d4efe4f92f6e68c8e0304ee83013016.png
favicon-f94a92edfd00b1cc38b6658933ba54fd.ico
font-awesome-7235b656c02e8e1a0af4839e29862cb0.css
font-awesome-7235b656c02e8e1a0af4839e29862cb0.css.gz
font-awesome.min-f44605a25d83e9849f7a91abbc1fa013.css
font-awesome.min-f44605a25d83e9849f7a91abbc1fa013.css.gz
font.helvetica-neue-3bee85020746eede72c4dcd3bf80bf91.css
font.helvetica-neue-3bee85020746eede72c4dcd3bf80bf91.css.gz
font.roboto-27de563886805db8510b1488e25a43ca.css
font.roboto-27de563886805db8510b1488e25a43ca.css.gz
fullcalendar-8c8f481e6c52d01d9089fb9276e301ed.css
fullcalendar-8c8f481e6c52d01d9089fb9276e301ed.css.gz
fullcalendar.min-e0e065736f355ad455f035972ee4f0f1.js
fullcalendar.min-e0e065736f355ad455f035972ee4f0f1.js.gz
gmaps-4e0a34409a72c75b23ead4560c2067ad.js
gmaps-4e0a34409a72c75b23ead4560c2067ad.js.gz
google_analytics-99bd28f02528c13b44624e84c5c90c83.js
google_analytics-99bd28f02528c13b44624e84c5c90c83.js.gz
holder-80b1ec50bf56cecf1ad3aa13205b728b.js
holder-80b1ec50bf56cecf1ad3aa13205b728b.js.gz
html5shiv-b943c98fa95fcffd9369e767949c2e8a.js
html5shiv-b943c98fa95fcffd9369e767949c2e8a.js.gz
instagram-icon-16abed513241b2885051980c313b9d47.png
jquery-1.11.1.min-89fdfdd2b961da1c1dac57e8beeff312.js
jquery-1.11.1.min-89fdfdd2b961da1c1dac57e8beeff312.js.gz
jquery2-f6430688c576903899df06242228577b.js
jquery2-f6430688c576903899df06242228577b.js.gz
jquery2.min-081439c47c59b5a03e286d1fbbd00553.js
jquery2.min-081439c47c59b5a03e286d1fbbd00553.js.gz
jquery-87424c3c19e96d4fb033c10ebe21ec40.js
jquery-87424c3c19e96d4fb033c10ebe21ec40.js.gz
jquery.autogrow-textarea-1db755051eeda2b4be077aba1883904c.js
jquery.autogrow-textarea-1db755051eeda2b4be077aba1883904c.js.gz
jquery.cookies-238dfd7d92c77c8d827e6e7df271e41d.js
jquery.cookies-238dfd7d92c77c8d827e6e7df271e41d.js.gz
jquery.datatables-2b6b927f456a60d7541726d69bd85eca.css
jquery.datatables-2b6b927f456a60d7541726d69bd85eca.css.gz
jquery.datatables.min-1f0cd1992a3aece4031123fd7fa1cb47.js
jquery.datatables.min-1f0cd1992a3aece4031123fd7fa1cb47.js.gz
jquery.gritter-d330d1b29b5213c7b69a1f4f1830419d.css
jquery.gritter-d330d1b29b5213c7b69a1f4f1830419d.css.gz
jquery.gritter.min-89110826c434b3cf1d6f58c5e7ddcb26.js
jquery.gritter.min-89110826c434b3cf1d6f58c5e7ddcb26.js.gz
jquery-jvectormap-1.2.2-b627cb9f9622cd8b2f0694578f32ea50.css
jquery-jvectormap-1.2.2-b627cb9f9622cd8b2f0694578f32ea50.css.gz
jquery-jvectormap-1.2.2.min-dd65e7b55b1b9df68da7896b0a1c77e1.js
jquery-jvectormap-1.2.2.min-dd65e7b55b1b9df68da7896b0a1c77e1.js.gz
jquery-jvectormap-us-aea-en-2118d2319e11000b32c7942e7d4b1b3e.js
jquery-jvectormap-us-aea-en-2118d2319e11000b32c7942e7d4b1b3e.js.gz
jquery-jvectormap-world-mill-en-7520a1f25b1fefbd129b81520fa33fc4.js
jquery-jvectormap-world-mill-en-7520a1f25b1fefbd129b81520fa33fc4.js.gz
jquery.maskedinput.min-f586a7257f244041eab790c5d211f37b.js
jquery.maskedinput.min-f586a7257f244041eab790c5d211f37b.js.gz
jquery-migrate-1.2.1.min-16a67272140ccc9c6aa87df04c15c468.js
jquery-migrate-1.2.1.min-16a67272140ccc9c6aa87df04c15c468.js.gz
jquery.min-eb8e576f52996bce7c557babc6e8a79e.js
jquery.min-eb8e576f52996bce7c557babc6e8a79e.js.gz
jquery.mousewheel-a78b3418946de2bdd2899b0fd7d8e009.js
jquery.mousewheel-a78b3418946de2bdd2899b0fd7d8e009.js.gz
jquery.prettyPhoto-f78f329a32e47bf51932d09c30564afa.js
jquery.prettyPhoto-f78f329a32e47bf51932d09c30564afa.js.gz
jquery.sparkline.min-639608ad39e4b3f2136934fed4dba81b.js
jquery.sparkline.min-639608ad39e4b3f2136934fed4dba81b.js.gz
jquery.tagsinput-da8da10523fb6f8ff3faf6903beb93e4.css
jquery.tagsinput-da8da10523fb6f8ff3faf6903beb93e4.css.gz
jquery.tagsinput.min-4d118b62ab063be6a215b5b26880c4fa.js
jquery.tagsinput.min-4d118b62ab063be6a215b5b26880c4fa.js.gz
jquery-ui-1.10.3-eeb57f0a91c90ebccc313b755d972670.css
jquery-ui-1.10.3-eeb57f0a91c90ebccc313b755d972670.css.gz
jquery-ui-1.10.3.min-8ff0c79f1466addcf6bf4aaf666799c8.js
jquery-ui-1.10.3.min-8ff0c79f1466addcf6bf4aaf666799c8.js.gz
jquery.ui.touch-punch.min-0062e10ac0b77dac44049f0b244a1343.js
jquery.ui.touch-punch.min-0062e10ac0b77dac44049f0b244a1343.js.gz
jquery_ujs-e27bd20a10d28155845a22d71ef94f2f.js
jquery_ujs-e27bd20a10d28155845a22d71ef94f2f.js.gz
jquery.validate.min-cc10e387641dc3a427c0b2a1d6a5cc08.js
jquery.validate.min-cc10e387641dc3a427c0b2a1d6a5cc08.js.gz
lato-9eab93d341daca0b64eb83e500c36c7d.css
lato-9eab93d341daca0b64eb83e500c36c7d.css.gz
Lookupkitten1-inverted-468ad96030a9c7c555a9e598eec25705.jpg
manifest-75f18e2d98f206cfb74b04585af62025.json
masonry.pkgd.min-39a9db9644583f39a4afc5245d1a7b48.js
masonry.pkgd.min-39a9db9644583f39a4afc5245d1a7b48.js.gz
modernizr.min-e85e2cf3694aba170e11bb364d4f38c8.js
modernizr.min-e85e2cf3694aba170e11bb364d4f38c8.js.gz
moment-1e5ae5b0dd501d933da017e415e6658d.js
moment-1e5ae5b0dd501d933da017e415e6658d.js.gz
morris-b2de433af8eec1719536e9b00c3d78cd.css
morris-b2de433af8eec1719536e9b00c3d78cd.css.gz
morris.min-544a2438115ee60523b71a1a99f94e34.js
morris.min-544a2438115ee60523b71a1a99f94e34.js.gz
pinterest-icon-0738f59cb68a09fbe0387c25b94cfe91.png
prettyPhoto-b0211d39e61dd455b051e9df2100c166.css
prettyPhoto-b0211d39e61dd455b051e9df2100c166.css.gz
publishing2-88893fd664cca1fb36e83ef0b1f05707.jpg
rails_bootstrap_forms-85a44da0cf14906976bde10ea0a42bbc.css
rails_bootstrap_forms-85a44da0cf14906976bde10ea0a42bbc.css.gz
raphael-2.1.0.min-7f08beb5a8d60af0dff9d34187bae9a9.js
raphael-2.1.0.min-7f08beb5a8d60af0dff9d34187bae9a9.js.gz
respond.min-943d23379ec213cd5fac370c1407a384.js
respond.min-943d23379ec213cd5fac370c1407a384.js.gz
retina.min-0a2f559b265ead424c27ab96d85d0b27.js
retina.min-0a2f559b265ead424c27ab96d85d0b27.js.gz
roboto
roboto-c2c7202e06866f7695a402846d6fc487.css
roboto-c2c7202e06866f7695a402846d6fc487.css.gz
select2-b4679ffd84b4af1e00b5e2f63c909de1.css
select2-b4679ffd84b4af1e00b5e2f63c909de1.css.gz
select2.min-dc009a4312724dfd32e04dc84c7cc822.js
select2.min-dc009a4312724dfd32e04dc84c7cc822.js.gz
style.bluenav-eef27f15d23db5d20d1fa45aacfb6c4a.css
style.bluenav-eef27f15d23db5d20d1fa45aacfb6c4a.css.gz
style.darkknight-41adb57795102ac40409822f26a389a8.css
style.darkknight-41adb57795102ac40409822f26a389a8.css.gz
style.default-84d0516848a763e0b8b8b7005f7ae816.css
style.default-84d0516848a763e0b8b8b7005f7ae816.css.gz
style.default-rtl-fe345a8404e132c62dba693b02debd84.css
style.default-rtl-fe345a8404e132c62dba693b02debd84.css.gz
style.dodgerblue-c3b44311e0db6c2ab5ea0c6bebd550da.css
style.dodgerblue-c3b44311e0db6c2ab5ea0c6bebd550da.css.gz
style.greyjoy-25f81d84ba89347d264f4aa2b84dbdbd.css
style.greyjoy-25f81d84ba89347d264f4aa2b84dbdbd.css.gz
style.inverse-ec1a47cdc185e55472a8115af3d99a8d.css
style.inverse-ec1a47cdc185e55472a8115af3d99a8d.css.gz
style.katniss-ccdda17b7614d5093fcf61465ae8aa9d.css
style.katniss-ccdda17b7614d5093fcf61465ae8aa9d.css.gz
toggles-428ccce58542ffa3ba9c1d3cfe253d36.css
toggles-428ccce58542ffa3ba9c1d3cfe253d36.css.gz
toggles.min-fea21bf806ff8388d5a8ad6ecd67fb47.js
toggles.min-fea21bf806ff8388d5a8ad6ecd67fb47.js.gz
tumblr-icon-6c8ddc711d5f3f9dc2e163268fc282c4.png
turbolinks-f87b3583ca50adb0488b031297f5580d.js
turbolinks-f87b3583ca50adb0488b031297f5580d.js.gz
twitter-icon-e96caf41d7a48f88f48a2e25e74e07d8.png
visitors-f2c7b5fd67318e31b093b301ddb1b606.js
visitors-f2c7b5fd67318e31b093b301ddb1b606.js.gz
weather-icons.min-463072e65eba39f9c8908b334705937e.css
weather-icons.min-463072e65eba39f9c8908b334705937e.css.gz
wordpress-icon-707488a657e1f5e8c018b0b2335d37ca.png
wysihtml5-0.3.0.min-d70870a054c85cf85d1d8ec0adc94935.js
wysihtml5-0.3.0.min-d70870a054c85cf85d1d8ec0adc94935.js.gz
wysiwyg-color-db6d982825da1878a5b105a812ba227e.css
wysiwyg-color-db6d982825da1878a5b105a812ba227e.css.gz
youtube-icon-e0a4bd918821ef87fc2f9410c9d1054a.png
I am not sure if you saw this page, but I had similar issue and this helped me out.
I would check to make sure you have config.serve_static_assets = true in your config/application.rb
If you do I would skip down to the debugging section
So after some trial and error and getting feedback, below are some take away that I hope can help others in the future. The short of it is that, if you face any problem, always refer to Rails Asset Pipeline. This is because different rails versions has different methods. At the point of this answer, mine is Rails Version: Rails 4.2.0. Ruby Version: ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin13.0]
Do note that this answer applied to my situation, may vary with yours.
My Problem Statement:
I bought a bootstrap template online and would like to incorporate it to my application. Below are the following steps I took to resolve the problem.
Put files into vendor/assets - I cut and paste all the templates into my vendors/assets folder. All of the assets are properly arranged into their respective fonts folders, images folders, javascript folders and stylesheets folder.
Only keep what I need - I removed the files that I do not need and only keep those that I need. This requires some reading of the vendor files.
Ensure correct assets path - after which I went through each each files and ensure that the files are referencing the assets correctly. Any css files that has image and font references, I changed it to css.erb format, then put <%= asset_path(...) %> into url(...). Note that there are various ways to do this i.e. use font_path or image_path, use css.scss instead of css.erb etc. Please refer to documentation from asset pipeline. I also removed any #import url('<your file>.css'); cause I will be using *= require <your files> later
Config application.js and application.css in app/assets - I then key in "require " into application.js and application.css manifest respectively based on the names of the files I have in my vendor/assets folder. D note that the order is important. The manifest reads from top to bottom. Therefore, always ensure pre-requisite files are kept above files that depends on it. For example, I have a default.css file that depends on font.css, hence *= require font.css comes before *= require default.css.
Create your view - then I created a some html.erb views files with controllers and routes.
Test development locally - Launch the app locally through rails s. If you put the files correctly in their respective folders in vendor/assets. Your application should show up nicely. Else, please refer to the instructions above and try again.
Config to test production locally - to test production locally, first, go to your secrets.yml file and change the production secret_key_base to the one secret_key_base from your development (IMPORTANT to revert this back to ENV once you are done testing),
Precompile and open rails app in production locally - Once you have configured, run RAILS_ENV=production rake assets:precompilein the
terminal. You should see your assets being precompiled. Once the
precompile is done, you should be able to find an assets folder in
your public folder (your images, videos and fonts assets should each
have their own files, whilst all css and js will be cramped into one file as application-<md5>.css and application-<md5>.js respectively). If this didnt workout properly, your precompile fails. It is most probably due to css or
js syntax error, go back and check the files and make the changes.
If you have made any corrective changes, please run rake assets:clobber to remove the public/assets then run the production precompile again. Once all is good, run the following command in your terminal rails s -e production, this
opens up your server locally but in production environment instead
of dev environment. When running localhost:3000 if your secret_key_base is not copied properly, you will see an error in your browser asking you to make changes to the secret key.
Viewing localhost:3000 in browser - If your view in local production is different from that of your local development view. For example, most of the css did not show up properly, troubleshoot by
right click on the parts of the website that is not reflected properly, click on inspect element, you should be able to see 404 errors. this means that your code or assets in .css and .js is not referenced or configured properly. go back to point 8 and redo.
check your rails server logs to find if there are any ActionController::RoutingError (No route matches [GET] "/assets/.... this means that your code or assets in .css and .js is not referenced or configured properly. go back to point 8 and redo.
Pushing to heroku - Once everything is good locally, you can now push to heroku. because you ran the precompile for production env locally, you will see that during your push to heroku, heroku will state something like remote: Detected manifest file, assuming assets were compiled locally. else, heroku will have to precompile for you. Note that heroku use rails_12factor gem in production. Additionally, these gems, sass-rails, coffee-rails, uglifier, come in default when you created your rails app which is essential for your asset pipeline.
Things I did not do to resolve my problem:
Though the methods below are valid,
I DID NOT use config.serve_static_assets = true for application.rb, production.rb or staging.rb
I DID NOT ran rake assets:precompile
I DID NOT ran heroku run rake assets:precompile
I DID NOT put Rails.application.config.assets.precompile += %w( *.css *.js ) in config/initializers/assets.rb
I DID NOT resort to using config.assets.compile = true
I DID NOT use config.assets.paths << Rails.root.join("lib", "videoplayer", "flash") in config/application.rb
Other links that could be helpful:
No route matches [GET] /assets
https://github.com/FortAwesome/font-awesome-sass/issues/48
Things I could not explain
This solution only worked when I recreated a new rails app. My old rails app did not work as when I ran precompile, the css and js files in public/assets were not in one application-<md5>.css and application-<md5>.js respectively. instead, they were scattered to their own font.css, default.css etc etc, as seen from "Output below" shown above. Will be doing more research to get down to the bottom of this.
I hope my answer above helped. Do give feedback if I made any mistakes or missed out anything.
Adding the vendor asset to precompile in assets.rb (f.e. Rails.application.config.assets.precompile += %w( highcharts.js ) worked form me, when deploying to Heroku. (and I didn't use a joker like *.js)
I added "jquery_mobile_rails" to my Gemfile and did bundle install. Then I added the following lines to my application.css.scss file:
//=require jquery.mobile
However when I run 'bundle exec rails s' and start my app I get this error:
couldn't find file 'jquery.mobile'
(in /Users/Me/Development/ruby/myapp/app/assets/stylesheets/application.css.scss:1)
I loaded the Rails app console and looked at the assets path config:
Rails.application.config.assets.paths
I get an array of paths which includes my Gemfile path with the jquery_mobile_rails gem and inside the vendor/assets/javascript I see the file jquery.mobile.js.
So why can't I include this in my application.css.scss?
You have mistakenly added the line for javascript(application.js) in the application.css . Please add the following line to your application.css.scss
*= require jquery.mobile
rails newbie here. Can't get development machine to process *= require ... in application.css manifest file. In development.rb I have
config.assets.compress = false
config.assets.compile = true
config.assets.debug = true
In app/assets/stylesheets there is application.css with
*= require_self
*= require_tree .
and the app.css.scss
If I request http://localhost:3000/assets/app.css The .scss is processed fine,
But the output application.css to the browser still has
*= require_self
*= require_tree .
in it, instead of the .scss file that is in the same directory. What do I need to enable the asset pipeline to process the require directives? bundle install is working fine. I have also tried with the precompile rake task with same results. It seems the directives are being ignored.
My include tag is <%= stylesheet_link_tag "application" %>
This is a Refinery site that I am trying to setup a development environment for.
Thanks in advance
Finally found out what was up. Had the wrong version of Ruby installed. Since this was an existing Rails application, the Gemfile specified gem versions which were I guess incompatible with ruby 2.0.0, which was what installed by default on my Ubuntu machine.
Fix:
rvm install 1.9.3
rvm use 1.9.3 --default
Everything looked beautiful until I deployed to Heroku, assets got precompiled, and now the ui is a horrible mess.
In my application.css I have:
*= require_self
*= require_tree .
In my app.css.scss I have:
$gridColumns: 14;
$gridColumnWidth: 70px;
.. etc ..
#import "bootstrap";
#import "font-awesome";
Why do the variable changes work in development but not in production? Debugging with firebug shows that the widths are based on the old grid system.
How can I get the values to be overwritten with precompiled assets?
I simply ran
$ RAILS_ENV=production bundle exec rake assets:precompile
and then committed to version control, deployed again, and it worked. Doesn't make sense, but I guess precompiling them yourself is different than what Heroku does.
I'm using the bootstrap-sass gem with my rails (3.2.5) app, and things are working great in my local dev environment. But when I deploy to prod on Heroku the bootstrap CSS isn't included in the compiled assets.
I added bootstrap-sass and sass-rails to my Gemfile:
gem 'bootstrap-sass', '2.0.3.1'
group :assets do
gem 'sass-rails', '3.2.4'
end
And I added an import for Bootstrap to a custom.css file in my assets dir:
#import "bootstrap";
Basic stuff. Any idea why this isn't working in Prod?
I was running into exact same problem. These are the steps I followed to resolve the issue:
Add " *= require bootstrap" right above " *= require_tree ." in application.css.
Then I did "bundle install --without production"
Then I ran "rake assets:precompile"
Then I did git add .
Then I committed the changes git commit -m "blah..."
Then push changes to production "git push heroku master"
You must add a bootstrap_and_overrides.css.scss file in your app/assets/stylesheets with the next:
// Set the correct sprite paths
$iconSpritePath: asset-url('glyphicons-halflings.png', image);
$iconWhiteSpritePath: asset-url("glyphicons-halflings-white.png", image);
#import "bootstrap";
#import "bootstrap-responsive";
Also, you must add in your application.js:
//= require bootstrap
Regards!