I can't get the foundation-icons to show in production-enviroment (deployment) while in development it works just fine.
When I start the server in production-mode via nginx and the gem puma, basically the only error I get is this:
ActionController::RoutingError (No route matches [GET] "/stylesheets/foundation-icons.css")
I've tried to add this to config/enviroments/production.rb:
config.assets.precompile += %w( vendor/foundation.scss )
and I precompiled using RAILS_ENV=production
I'm using the latest version of foundation:
gem 'foundation-rails', github: 'ahacking/foundation-rails'
Using ruby 2.0.0.p353 and Rails 4.0.2.
Edit:
Foundation-icons has no real relation to the foundation gem. (I wasn't the guy who implemented it in the application)
Edit 2:
Added config.assets.compile = true in config/environments/production.rb witch removed the error, however the icons are still missing.
I found a gem for foundation-icons that works like a charm
https://github.com/zaiste/foundation-icons-sass-rails
Related
I deployed a rails application with Dokku. Everything went fine except that all my assets including images returns a 404 error.
I really don't know how to debug this.
For dokku it is simple to add:
dokku config:set <your-app> RAILS_SERVE_STATIC_FILES=true
I had exact same issue and adding the following gem solved it:
gem 'rails_12factor', group: :production
That's the official way of dealing with that issue on Heroku for Rails 3 and 4 (and that gem is made by Heroku team as well).
On rails 5, try making the changes in production.rb that are suggested on this page rails_12f
Finally I just added this :
config.serve_static_files = true
in environements/production.rb
Note: flag deprecated in Rails 5.0 in in favor of config.public_file_server.enabled
I am currently working on a Rails application that uses the bootstrap-sass gem to help style some of my front end views. When running locally, I have no problem browsing the views. After Heroku deployment, I receive the following error:
ActionController::RoutingError (No route matches [GET] "/assets/bootstrap-responsive.css")
Here is a snippet of my application.rb file:
# Enable the asset pipeline
config.assets.enabled = true
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
config.assets.compile = true
config.assets.initialize_on_precompile = false
Any thoughts as to how to get bootstrap-sass working on a Heroku deployment with asset pre-compilation?
Did you install the 12factor gem? You'll need that with Rails
gem 'rails_12factor', group: :production
https://devcenter.heroku.com/articles/getting-started-with-rails4#heroku-gems
I had my bootstrap import statements in my application.css file. By moving to a bootstrap_and_overrides.css.scss file, my problem was solved.
This post helped: Getting bootstrap-sass bootstrap CSS into production on Heroku
Environment: heroku
Rails: 4
Ruby: 2
We deployed an app to heroku, and it seemed as though anything in the public folder was not accessible (didn't see the static file so the router kicked in and then complains about no route matching).
To get around this, we set
# Rails 4 only flag
config.serve_static_assets = true
in our production.rb file. Is this really the best way to handle this? Or did we fail to configure the app some how to be hosted on heroku properly?
This is deprecated in Rails 4.2, and it is now an alias slated to be removed in Rails 5.0
config.serve_static_assets = true
It should be changed to:
config.serve_static_files = true
In previous Rails versions, Heroku injected a plugin that enabled serving of static assets so this issue didn't exist. As this plugin system was removed in Rails 4, they now created a gem which does the same. You enable it in your Gemfile via:
gem 'rails_12factor', group: :production
See Getting Started with Rails 4.x on Heroku
You could also of course use a CDN for your assets, but you're not required to.
For Rails 5+ work on twelve-factor platforms out of the box and the gem is no longer required
As Dean Winchester mentioned it, it is a good idea to use a CDN for your static assets. In fact when using only Heroku your Rails application would have to be responsible to serve static assets since Heroku Cedar architecture will not do that for you.
Setting config.serve_static_assets = true is the way to go if you don't want to configure a CDN and use only Heroku.
The rails guides are wrong. Try...
config.assets.serve_static_files = true
I'm using compass-rails gem in my Rails app. I'm using rails 3.2 and trying to deploy on Heroku cedar stack.
Assets precompilation seemed to pass without any problems.
I keep getting the following error (in the log) when trying to access the site:
ActionView::Template::Error (File to import not found or unreadable: compass.
What am I doing wrong?
I found the problem. Apparently, Heroku must have the following configuration set:
config.assets.initialize_on_precompile = false
I added it and everything works fine now.
I'm trying to port my rails 3.0.7 project to rails 3.1
I have Phusion Passenger running on nginx + rvm.
There is config.assets.enabled = true in my application.rb file.
I created empty rails 3.1 project and copied my app directory, routes.rb and application.rb files over it. I moved everything from public to app/assets (app/assets/stylesheets etc).
When I'm trying to access assets (application.css/application.js), I'm getting 404 not found error, but I can see them in app/assets/stylesheets/application.css and app/assets/javascripts/application.js.
Help me please.
UPD: Thanks to Devin M for the idea, I removed css,js,gif,png and jpg extensions from nginx.conf ("serve static files directly") and everything started to work.
I came to this question with a similar problem (everything was giving a 404) I found that Rails 3.1.0.rc4 has a problem with gem 'sprockets'
In your Gemfile set:
gem 'sprockets', '= 2.0.0.beta.10'
Note: you may have to manually override your Gemfile.lock before you bundle install
Usually this is a problem with the nginx config not set up to serve things correctly. Double check your config files.