I have a Rails app on Heroku staging server and everything has gone well except for the error pages aren't working. Every time I get a "status: 500" error, it results in a blank white page, NOT the 500.html static error page.
I have a static 500.html page in the my_app/public folder, and I can access it in heroku if I try to do so directly via myapp.herokuapp.com/500. It will display fine then. But if I get a real "status: 500" error in the program, it will not render the 500.html page... rather, it renders a blank white page.
To create an error, I attempted to go to a non-existent page.
The logs indicate that the "status: 500" error has occured, but again, white page. Here is part of the output from the logs:
heroku[router]: at=info method=GET path="/fakepage" host=myapp.herokuapp.com request_id=20825-b474-4e-37f-c52486140 fwd="67.xxx.xxx.x" dyno=web.1 connect=1ms service=108ms status=500 bytes=949
Started GET "/fakepage" for xx.xxx.xxx.x at 2014-08-24 03:50:31 +0000
app[web.1]: ** [Raven] User excluded error: #<ActionController::RoutingError: No route matches [GET] "/fakepage">
In the config/environment/staging.rb I have the following:
config.consider_all_requests_local = false
config.serve_static_assets = true #after the default of false didn't work
It seems like this shouldn't be one of those "tough issues"... and not finding any prior posts or articles that directly related to my question makes me think it must be something inane on my part. I'm currently running Ruby 2.0.0p451 & Rails 4.1.1. I have Sentry setup through heroku for monitoring errors. Let me know if there's any other useful info I could provide.
EDIT
I should mention that my Gemfile looks like this:
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails' #, '4.1.1'
gem 'bcrypt'
gem 'bootstrap_form'
gem 'bootstrap-sass'
gem 'carrierwave'
gem 'coffee-rails'
gem 'dropzonejs-rails'
gem 'email_validator'
gem 'fog'
gem 'geocoder'
gem 'haml-rails'
gem 'jquery-rails'
gem 'jquery-turbolinks'
gem 'jquery-ui-rails'
gem 'mini_magick'
gem 'paratrooper'
gem 'sass-rails'
gem 'sidekiq'
gem 'sinatra', require: nil
gem 'turbolinks'
gem 'uglifier'
gem 'unicorn'
group :production, :staging do
gem 'pg'
gem 'rails_12factor'
gem 'sentry-raven'
end
That is, I do have the gem 'rails_12factor' in the correct group for both staging & production environments as noted in a similar question regarding serving static assets in heroku with Rails4... essentially what an error page would be doing.
I have the app setup to run multiple processes through Unicorn, and have Unicorn temporarily setup to handle Sidekiq processes internally while the app is in testing (to avoid a second dyno). Also running Redis.
config/environments/staging.rb
Rails.application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = true
config.assets.js_compressor = :uglifier
config.assets.compress = true
config.assets.compile = true #WAS FALSE
config.assets.digest = true
config.assets.version = '1.0'
config.action_mailer.default_url_options = { host: "..." }
config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:port => ENV['MAILGUN_SMTP_PORT' ],
:address => ENV['MAILGUN_SMTP_SERVER' ],
:user_name => ENV['MAILGUN_SMTP_LOGIN' ],
:password => ENV['MAILGUN_SMTP_PASSWORD'],
:domain => '...',
:authentication => :plain }
config.log_level = :info #see everything in the log
config.i18n.fallbacks = true
config.log_formatter = ::Logger::Formatter.new
config.action_dispatch.show_exceptions = false #per sentry-raven docs
config.active_record.dump_schema_after_migration = false
config.active_support.deprecation = :notify #send to registered listeners
I finally got to the bottom of the issue.
The conclusion is that Heroku will serve the basic error pages when a status error (404, 500, etc) happens in a vanilla Rails application without any custom classes. After I determined that, it helped direct the diagnosis.
Looking through the config/environments/staging.rb code, I saw the LOC that sentry-raven stipulated in their docs should be set to false:
config.action_dispatch.show_exceptions = false #per sentry-raven docs
After setting this back to true, the status error pages started functioning:
config.action_dispatch.show_exceptions = true #status error pages work again!
So, I may have been misunderstanding sentry-raven's docs & incorporating it incorrectly into the Rails app configs, or something otherwise, but that's what the issue turned out to be.
So, if you your Heroku hosted Rails app is performing fine and then runs into the "white screen of death" upon any status error, this is one more thing to check in your attempts to diagnose.
Related
I have a relatively new Rails 6 app (Rails 6.1.3.1), so there's not a whole lot of customization yet. However, I cannot get session variables to persist.
For example, if I put something like the following in a controller action:
class PagesController < ApplicationController
skip_before_action :authenticate_user!
def home
byebug
session[:foo] = 'bar'
end
end
I would expect session[:foo] to be nil on the first request, but I would expect it to be set to 'bar' on all subsequent requests. However, it's nil every time.
This is causing a major problem with CSRF functionality, because the session[:_csrf_token] is being reset on every request. This means that no request has a valid CSRF token, so I can't get login to work.
For the life of me, I cannot figure out what is going on. I've tried monkeying around with browser settings and environment settings, but nothing has worked.
I've been banging my head on this for a couple days now. What am I missing? What might cause the session to be reset on every request?
Here is some more context:
# Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '3.0.1'
gem 'rails', '6.1.3.1'
gem 'pg'
gem 'puma'
gem 'bootsnap', require: false
gem 'jbuilder'
gem 'webpacker'
gem 'redis'
gem 'autoprefixer-rails'
gem 'aws-sdk-s3'
gem 'delayed_job_active_record'
gem 'devise'
gem 'image_processing'
gem 'kaminari'
gem 'money-rails'
gem 'pg_search'
gem 'postmark-rails'
gem 'pundit'
gem 'roadie-rails'
gem 'rollbar'
gem 'sassc-rails'
gem 'tailwindcss-rails'
gem 'view_component', require: 'view_component/engine'
group :development, :test do
gem 'byebug'
end
group :development do
gem 'guard'
gem 'guard-minitest'
gem 'binding_of_caller'
gem 'listen'
gem 'spring'
gem 'web-console'
end
group :test do
gem 'capybara'
gem 'minitest-focus'
gem 'minitest-rails'
gem 'minitest-reporters'
gem 'mocha'
gem 'pdf-inspector'
gem 'selenium-webdriver'
gem 'rexml'
gem 'webdrivers'
end
group :development, :production do
gem 'stripe'
end
# application.rb
require_relative "boot"
require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
class Env
def self.var(*args)
var = args.join('_').upcase
ENV[var] || Rails.application.credentials[Rails.env.to_sym].dig(*args)
end
end
module Foobar
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.1
# Configuration for the application, engines, and railties goes here.
#
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
#
# config.time_zone = "Central Time (US & Canada)"
# config.eager_load_paths << Rails.root.join("extras")
config.autoload_paths += %W( #{config.root}/app/components )
config.autoload_paths += %W( #{config.root}/app/forms )
config.autoload_paths += %W( #{config.root}/app/utilities )
# Look in components folder when determining which classes to include.
config.assets.css_compressor = Tailwindcss::Compressor.new(files_with_class_names: Rails.root.glob("app/components/**/*.*"))
end
end
# application_controller.rb
class ApplicationController < ActionController::Base
include Pundit
protect_from_forgery with: :reset_session, prepend: true
before_action :authenticate_user!
default_form_builder Forms::Builder
attr_writer :title
helper_method :body_class, :title
def authorize(record, query = nil)
super([:authorization, record], query)
end
def body_class
"#{params[:controller].gsub('/', '_')}"
end
def policy_scope(scope)
super([:authorization, scope])
end
def title
#title || default_title
end
private
def default_title
controller_name.singularize.humanize.capitalize
end
end
# development.rb
require "active_support/core_ext/integer/time"
Rails.application.configure do
config.session_store :cache_store
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports.
config.consider_all_requests_local = true
# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :local
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
config.action_mailer.perform_caching = false
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise exceptions for disallowed deprecations.
config.active_support.disallowed_deprecation = :raise
# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = false
# Suppress logger output for asset requests.
config.assets.quiet = true
# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true
# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true
# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
end
Ok, found the problem. Turns out that I had copied the setting config.session_store :cache_store in development.rb from a different project I had been working on. However, this setting was added as part of the StimulusReflex setup for that other project.
From the StimulusReflex docs:
Cookie-based session storage is not currently supported by StimulusReflex.
Instead, we enable caching in the development environment so that we can assign our user session data to be managed by the cache store.
The default setting for this option is cookie_store. By changing it to :cache_store without specifying a cache repo, it implements ActionDispatch::Session::CacheStore and defaults to storing it in Rails.cache, which uses the :file_store option, which dumps it in tmp/cache.
However, further down in development.rb, there is some conditional logic that assigns config.cache_store to :null_store if there is no caching-dev.txt file. This implements ActiveSupport::Cache::NullStore, which is "a cache store implementation which doesn't actually store anything."
So because I had not enabled caching with rails dev:cache for this project, the session cache was getting toasted with every request.
LESSON LEARNED: Be very careful when copying config settings from an old project to a new one!
I'm using ngannotate-rails to help get angular code to work in a compressed format. This is in a Rails 3.2 + Angular 1.5.x app.
I've added the following to my Gemfile and ran bundle
group :assets do
gem 'sprockets-derailleur', '~> 1.0.0' # Speed up precompiles with multi-core compile
gem 'turbo-sprockets-rails3', '~> 0.3.14' # Compile only changed assets
gem 'sass-rails', ' ~> 3.2' # Main CSS extension in use
gem 'less', '~> 2.6.0' # Less required for ui-utils plugin for AngularJS
gem 'therubyracer', '~> 0.12.1' # v8 library required for less
gem 'coffee-rails' # Language which compiles into JS
gem 'uglifier' # JS parser, minifier, compressor or beautifier toolkit
gem 'ngannotate-rails', '~> 1.2' # AngularJS minifier
end
Then in config/environments/development.rb I've added the following
if ENV['NG_FORCE'] == 'true'
config.assets.compress = true
config.assets.compile = true
config.assets.digest = true
config.assets.debug = false
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.precompile += %w(*.css *.js *.woff *.eot *.svg *.ttf) # The fix for font-awesome
else
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true
end
I then do the following commands but ng-annotate is not annotating
NG_FORCE=true RAILS_ENV=development bundle exec rake assets:clean assets:precompile:primary
NG_FORCE=true rails s
I check the compiled output in public/assets/.../ and I get this at the top;
(function(){var e;e=function(e,n,t,i,o,c,r,a,u,d,s,l,v,f,g,h,m,p,b,k,y,I,T,E,q,w,A){var D,P,F,x,j;
It's minified but not annotated with the strings so AngularJS throws this error;
application-57db964b9323e90284f1f3c331c9c3aa.js:43 Error: [$injector:unpr] Unknown provider: eProvider <- e <- InvoicesController
http://errors.angularjs.org/1.5.7/$injector/unpr?p0=eProvider%20%3C-%20e%20%3C-%20InvoicesController
at http://localhost:3000/assets/application-57db964b9323e90284f1f3c331c9c3aa.js:41:28591
at http://localhost:3000/assets/application-57db964b9323e90284f1f3c331c9c3aa.js:42:16654
at Object.r [as get] (http://localhost:3000/assets/application-57db964b9323e90284f1f3c331c9c3aa.js:42:15610)
at http://localhost:3000/assets/application-57db964b9323e90284f1f3c331c9c3aa.js:42:16739
at r (http://localhost:3000/assets/application-57db964b9323e90284f1f3c331c9c3aa.js:42:15610)
at o (http://localhost:3000/assets/application-57db964b9323e90284f1f3c331c9c3aa.js:42:15910)
at Object.s [as instantiate] (http://localhost:3000/assets/application-57db964b9323e90284f1f3c331c9c3aa.js:42:16247)
at http://localhost:3000/assets/application-57db964b9323e90284f1f3c331c9c3aa.js:43:9470
at http://localhost:3000/assets/application-57db964b9323e90284f1f3c331c9c3aa.js:98:32136
at Object.<anonymous> (http://localhost:3000/assets/application-57db964b9323e90284f1f3c331c9c3aa.js:47:31053) <div id="wrapper" class="ui-wrapper ng-scope" ui-view="">
UPDATE
InvoicesController
InvoicesController = ($scope, $http, $location, $state, $stateParams, $uibModal, $timeout, flash, Invoice, Division, Costing, Job, JobService, Common, ShortcutService, InvoiceService, TimesheetService, DisbursementService, DebtorService, SearchService, LineItemService, DateService, $filter, $mdDialog, $mdMedia, Restangular, hotkeys) ->
<Snip: Too long>
switch $state.current.name
# Index
when "invoices"
$scope.query = SearchService.getFilter('invoices')
page = SearchService.getPage('invoices')
if ($scope.query)
# Filter already exists
$scope.filterForm = true
getInvoices(angular.extend({}, $scope.query, {page: page, limit: 10, search: $scope.query}))
else if page > 0
$scope.query = { order: '-invoice_no', limit: 10, page: page }
$scope.onPaginate(page, 10)
else
$scope.resetFilter()
<Snip>
angular
.module('paisApp')
.controller('InvoicesController', InvoicesController)
Although it might have been cut off in your snippet above, I don't see where you would have provided the "ngInject" directive in you code.
I would expect your controller code to look like
MyController = ($scope, ...) ->
"ngInject"
# etc
It's the "ngInject" that ng-annotate looks for as the hook in points when transpiling the code.
I have capybara and when I run my Featured tests raised an error, it says about pending migrations in test environment, but when a run other type of test everything is good. I've already run all my migrations in test environment, I've already run rails in test and development envs.
this is my gemfile
group :development, :test do
.... other gems ....
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'database_cleaner'
gem 'capybara', '~> 2.5.0'
gem 'capybara-webkit', '~> 1.7.1'
gem 'selenium-webdriver'
gem 'poltergeist'
gem 'launchy-rails', '~> 0.0.1'
end
this is my test
# spec/features/sign_in_spec.rb
require 'rails_helper'
feature 'Visitor signs up' do
it "signs me in", :type => :feature do
visit new_user_session_path
puts "page: #{page.html.inspect}"
save_and_open_page
end
end
Thanks!
UPDATE:
I just try with this command:
bin/rake db:drop db:create db:migrate RAILS_ENV=test
Everything is ok with that command. Then I run my server with:
rails s -e test
Same error in my browser, "ActiveRecord::PendingMigrationError"
http://localhost:3000/
Then I run migrate command
bin/rake db:migrate RAILS_ENV=test
But it raised an error "ActiveRecord::StatementInvalid: PG::DuplicateTable: ERROR: relation "users" already exists"
And same error when a I run the features tests.
Here are my helpers: https://gist.github.com/israelb/e2f4b10ba5f94e1e8df2
There may be some kind of migration issue. Try rake db:test:prepare see if that helps.
I found the solution, I was a problem in my config/enviroment/test.rb file, I had to change by this one:
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure static file server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600'
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Randomize the order test cases are executed.
config.active_support.test_order = :random
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end
I've upgraded to Rails 4.1 and am trying to set up the exception_notification-rake gem to notify me by email of failed rake tasks.
In my Gemfile, I have gem 'exception_notification-rake'.
In development.rb, I have the following:
MyApp::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
# Specify what domain to use for mailer URLs
config.action_mailer.default_url_options = {host: "localhost:3000"}
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'gmail.com',
:user_name => Rails.application.secrets.email['user'],
:password => Rails.application.secrets.email['pass'],
:authentication => 'login',
:enable_starttls_auto => true
}
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
config.after_initialize do
Bullet.enable = true
Bullet.alert = true
Bullet.bullet_logger = true
Bullet.console = true
# Bullet.growl = true
Bullet.rails_logger = true
Bullet.add_footer = true
end
config.middleware.use ExceptionNotification::Rack,
:ignore_if => lambda { |env, exception| !env[:rake?] },
:email => {
:sender_address => %{"notifier" myemail#gmail.com},
:exception_recipients => %w(myemail#gmail.com)
}
ExceptionNotifier::Rake.configure
end
As you can see, I'm passing in the user and password using Rails 4.1's secrets.yml file.
When I try starting up my Rails server, I get the following error:
/development.rb:52:in `
block in <top (required)>': uninitialized constant ExceptionNotification (NameError)
I'm guessing this is a bug in the exception_notification-rake gem which calls a previous version of the exception_notification, but I'm not sure. Any help with this would be appreciated!
Thanks :)
Update:
I've notified the exception_notification-rake gem developer about this. I have all the prerequisite gems and have a fairly vanilla setup so I think this might be a bug that needs to be fixed for Rails 4.1
As can be seen in this issue the current, published, version of ExceptionNotification does not work with rails 4.1
Until the new version is released, you can just use the master version. In your Gemfile include your gem as follows:
gem 'exception_notification', github: 'smartinez87/exception_notification'
The maintainer has released a rc-version, which you can use as follows
gem 'exception_notification', '4.1.0.rc1'
Once the new gem version is released, you can switch to the released version (4.1.0). This should not take too long I guess ;)
I made a basic rails app with a simple pages controller with an index function and when I load the page I get:
ActionView::Template::Error (application.css isn't precompiled):
2: <html>
3: <head>
4: <title>Demo</title>
5: <%= stylesheet_link_tag "application" %>
6: <%= javascript_include_tag "application" %>
7: <%= csrf_meta_tags %>
8: </head>
app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__43625033_88530400'
Gemfile
source 'http://rubygems.org'
gem 'rails', '3.1.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'execjs'
gem 'therubyracer'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
end
gem 'jquery-rails'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
By default Rails assumes that you have your files precompiled in the production environment, if you want use live compiling (compile your assets during runtime) in production you must set the config.assets.compile to true.
# config/environments/production.rb
...
config.assets.compile = true
...
You can use this option to fallback to Sprockets when you are using precompiled assets but there are any missing precompiled files.
If config.assets.compile option is set to false and there are missing precompiled files you will get an "AssetNoPrecompiledError" indicating the name of the missing file.
You will get better performance in production if you set config.assets.compile to false in production.rb and precompile your assets. You can precompile with this rake task:
bundle exec rake assets:precompile
If you are using Capistrano, version 2.8.0 has a recipe to handle this at deploy time. For more info, see the "In Production" section of the Asset Pipeline Guide:
http://guides.rubyonrails.org/asset_pipeline.html
OK - I had the same problem. I didn't want to use "config.assets.compile = true" - I had to add all of my .css files to the list in config/environments/production.rb:
config.assets.precompile += %w( carts.css )
Then I had to create (and later delete) tmp/restart.txt
I consistently used the stylesheet_link_tag helper, so I found all the extra css files I needed to add with:
find . \( -type f -o -type l \) -exec grep stylesheet_link_tag {} /dev/null \;
A quick fix for capistrano user is to put this line to Capfile
# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'
For all those who are reading this but do not have problem with application.css and instead with their custom CSS classes e.g. admin.css, base.css etc.
Solution is to use as mentioned
bundle exec rake assets:precompile
And in stylesheets references just reference application.css
<%= stylesheet_link_tag "application", :media => "all" %>
Since assets pipeline will precompile all of your stylesheets in application.css. This also happens in development so using any other references is wrong when using assets pipeline.
I was having the exact same error in my development environment. In the end all I needed to do in order to fix it was to add:
config.assets.manifest = Rails.root.join("public/assets")
to my config/environments/development.rb file and it fixed it. My final config in development related to assets looks like:
config.assets.compress = false
config.assets.precompile += %w[bootstrap-alerts.js] #Lots of other space separated files
config.assets.compile = false
config.assets.digest = true
config.assets.manifest = Rails.root.join("public/assets")
config.assets.debug = true
I also had this issue, where trying to run in production without precompiling it would still throw not-precompiled errors. I had to change which line was commented application.rb:
# If you precompile assets before deploying to production, use this line
# Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
Bundler.require(:default, :assets, Rails.env)
Here's the quick fix:
If you're using capistrano do this add this to your deploy.rb:
after 'deploy:update_code' do
run "cd #{release_path}; RAILS_ENV=production rake assets:precompile"
end
cap deploy
I ran into this error message today and wanted to post the resolution to my particular my case. It turns out that my problem was that one of my css files was missing a closing brace and this was causing the file to not be compiled. It may be harder to notice this if you have an automated process that sets everything up (including the asset precompile) for your production environment.
After all else failed...
My solution was to change the layout file from
= stylesheet_link_tag "reset-min", 'application'
to
= stylesheet_link_tag 'application'
And it worked! (You can put the reset file inside the manifest.)
Just another way to fix this up on Heroku: Make sure your Rakefile is committed and pushed.
On heroku server (readonly filesystem),
If you want runtime compilation of css (its not recommended but you can do it), make sure you have done settings like below -
# inside config/application.rb
config.assets.enabled = true
config.assets.prefix = Rails.root.join('tmp/assets').to_s
# If you are using sass then keep gem outside of asset group
gem 'sass-rails', '3.1.4'
# inside config/environments/production.rb
config.assets.compile = true
if you think you followed everything good but still unlucky, just make sure you/capistrano run touch tmp/restart.txt or equivalent at the end. I was in the unlucky list but now :)
You probably have a syntax error in the css you are using.
Run this command
$ bundle exec rake assets:precompile RAILS_ENV=development --trace
It will give the exception, fixed that and you are all done.
Thanks