rake assets:precompile stuck - ruby-on-rails

couple of days ago i noticed that jquery calendar is not working on my deployment site(heroku). on digging out the problem i noticed that source of site on my dev server has some 100 script tags related to bootstrap(i am using twitter bootstrap css) but on prod server. i have 4 script tags. on searching i found that i should run rake assets:precompile on my rails console fo asset pipeline. but while running it is taking terribly long time, last time it took 6 hours and i had to abort it.
referring to many sites and post, i found that i should change config.serve_static_assetsto true and config.assets.compile to true. but problem is still there. i also tried to remove jquery-rails/jquery-ui-rails from gembut problem is still there.
here is my config/environmnets/production.rb
ProductRecall::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = true
# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
# Generate digests for assets URLs
config.assets.digest = true
# Specifies the header that your server uses for sending files
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
# config.active_record.auto_explain_threshold_in_seconds = 0.5
config.action_controller.perform_caching = false
end
my config/application.rb looks like this
require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
if defined?(Bundler)
# 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)
end
module ProductRecall
class Application < Rails::Application
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true
# Enforce whitelist mode for mass assignment.
# This will create an empty whitelist of attributes available for mass-assignment for all models
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
# parameters by using an attr_accessible or attr_protected declaration.
config.active_record.whitelist_attributes = true
# 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.action_mailer.default_url_options = { host: 'localhost:3000' }
end
end
here is my Gem file:
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'bootstrap-sass', '2.1'
gem 'bcrypt-ruby', '3.0.1'
gem 'therubyracer', :platforms => :ruby, :platforms => :ruby
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'bootstrap-datepicker-rails'
gem "google_visualr", "~> 2.1.0"
gem 'twitter-bootstrap-rails'
gem "galetahub-simple_captcha", :require => "simple_captcha"
gem 'rufus-scheduler'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.11.0'
end
group :development do
gem 'annotate', '2.5.0'
end
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.2'
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '4.1.0'
gem 'cucumber-rails', '1.2.1', :require => false
gem 'database_cleaner', '0.7.0'
end
#gem 'jquery-ui-rails'
group :production do
gem 'pg', '0.12.2'
end
plz let me know what is wrong here. as i am terribly stuck with no clue since 2 days

I had also faced the same problem. Actually gem gets conflict. Here 'rufus-scheduler' gem is the culprit. Try to remove the gem and deploy.
Next you can try this
task :precompile, :roles => :web, :except => { :no_release => true } do
run_locally("rm -rf public/assets/*")
run_locally("bundle exec rake assets:precompile")
servers = find_servers_for_task(current_task)
port_option = port ? " -e 'ssh -p #{port}' " : ''
servers.each do |server|
run_locally("rsync --recursive --times --rsh=ssh --compress --
human-readable #{port_option} --progress public/assets #{user} ##{server}: {shared_path}")
end
end

Related

uninitialized constant Paperclip::Storage::S3::AWS. I am getting this error when i am trying to upload an image to aws-s3 using paperclip

Gemfile
source 'http://rubygems.org'
gem 'rails', '4.2.4'
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
gem 'searchkick'
gem 'cocoon'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'foundation-rails'
gem 'tinymce-rails', '~> 4.3', '>= 4.3.8'
gem 'haml'
gem 'font-awesome-rails', '~> 4.6', '>= 4.6.1.0'
gem 'simple_form'
gem 'paperclip', '~> 4.3', '>= 4.3.6'
gem 'omniauth-facebook'
gem 'acts_as_votable'
gem 'masonry-rails', '~> 0.2.4'
gem 'aws-sdk', '~> 2.2', '>= 2.2.35'
gem 'foreman'
gem 'puma'
gem 'omniauth'
gem 'jquery-turbolinks', '~> 2.1'
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Production.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
config.paperclip_defaults = {
storage: :s3,
:s3_region => ENV['AWS_REGION'],
s3_credentials: {
bucket: ENV['S3_BUCKET_NAME'],
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
}
}
end
paperclip.rb
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = ":class/:attachment/:id_partition/:style/:filename"
Paperclip::Attachment.default_options[:s3_host_name] = 's3-us-west-2.amazonaws.com'
Details of Problem
*Problem is that when we use aws-sdk ~>2.0 Shows above error in the title while I am uploading image using paperclip for my heroku app. There is similar question but answer to that question is valid now as gem 'aws-sdk','~<2.0' is depracted now. It give corrupted gem error when tried to install. I am stuck in this for 2 days. Couldn't find any satisfactory answer from any resource. Thank you in advance *

Paperclip with S3 working fine on Localhost but Giving Error on Heroku

Gemfile
source 'http://rubygems.org'
gem 'rails', '4.2.4'
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
gem 'searchkick'
gem 'cocoon'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'foundation-rails'
gem 'tinymce-rails', '~> 4.3', '>= 4.3.8'
gem 'haml'
gem 'font-awesome-rails', '~> 4.6', '>= 4.6.1.0'
gem 'simple_form'
gem 'paperclip', '~> 4.3.6'
gem 'omniauth-facebook'
gem 'acts_as_votable'
gem 'masonry-rails', '~> 0.2.4'
gem 'aws-sdk', '~> 1.66.0'
gem 'foreman'
gem 'puma'
gem 'omniauth'
gem 'jquery-turbolinks', '~> 2.1'
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Production.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
config.paperclip_defaults = {
:storage => :s3,
:s3_protocol => 'http',
:s3_credentials => {
:bucket => ENV['S3_BUCKET_NAME'],
:access_key_id => ENV['AWS_ACCESS_KEY'],
:secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
}
end
Paperclip.rb
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'
I am running into this error
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
Image uploading is working Perfectly fine on localhost.I don't why It is giving this error on Heroku. I checked the credentail config environment variable,they are correct.No problem with them.Even with heroku logs,Nothing else could be deduce rather than status:500. Can someone help me out to either get Full error message for heroku logs for knowing error or Let me know what is wrong with above code. Thanx a lott in advance
Here are some helpful debugging settings for your Heroku app.
In production.rb:
# More meaningful logs
config.log_level = :debug
# More meaningful error pages
config.consider_all_requests_local = true
I figured out Error by setting:
Production.rb
# More meaningful logs
config.log_level = :debug
# More meaningful error pages
config.consider_all_requests_local = true
In my case there was problem with :s3_region,I fixed it by config ENV variable for heroku
heroku config:set AWS_REGION=us-east-1

How come helper.distance_of_time_in_words_to_now Time.now works in development but not production

I can call
helper.distance_of_time_in_words_to_now Time.now in development and it works just fine, but for some reason in production I am now getting translation missing: en.datetime.distance_in_words.less_than_x_minutes
What can I do to fix this?
Here is my gemfile:
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.5'
gem 'pg', '0.17.1'
gem 'sass-rails', '~> 4.0.3'
gem 'coffee-rails', '~> 4.0.1'
gem 'uglifier', '>= 2.5.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem "bootstrap-sass", "~> 3.1.1.1"
gem "will_paginate", "~> 3.0.5"
gem "bootstrap-will_paginate", "~> 0.0.10"
gem "redcarpet", "~> 3.1.1"
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0.7'
group :development, :test do
gem "foreman", "~> 0.63.0"
gem 'annotate', '~> 2.6.3'
gem 'rspec-rails', '~> 2.14.2'
gem "guard-rspec", "~> 4.2.3", :require => false
gem "factory_girl_rails", "~> 4.4.0"
gem "guard-spork", "~> 1.5.1"
gem "spork-rails", "~> 4.0.0"
# gem 'spork-rails', github: 'sporkrb/spork-rails'
end
group :test do
gem 'rb-fsevent', '~> 0.9.4', :require => false
gem "growl", "~> 1.0.3"
# # Test gems for Linux
# gem 'rb-inotify', '0.8.8'
# gem 'libnotify', '0.5.9'
# # Test gems for Windows
# gem 'rb-fchange', '0.0.5'
# gem 'rb-notifu', '0.0.4'
# gem 'win32console', '1.3.0'
end
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
gem 'dotenv-rails'
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'
# Use unicorn as the app server
gem 'unicorn', '~> 4.8.2'
gem 'unicorn-worker-killer', "~> 0.4.2"
# Authentication
gem "devise", "~> 3.2.4"
gem "cancan", "~> 1.6.10"
gem "geocoder", "~> 1.2.0"
gem "carrierwave", "~> 0.10.0"
gem "mini_magick", "~> 3.7.0"
gem "fog", "~> 1.22.0"
gem "unf", "~> 0.1.3" # for use with the fog gem
gem "validate_url", "~> 0.2.0"
gem 'psych', '~> 2.0.5'
gem 'paper_trail', '~> 3.0.1'
gem 'faraday', '~> 0.9.0'
# Use Capistrano for deployment
group :development do
gem "capistrano", "~> 3.2.1"
gem 'capistrano-rbenv', '~> 2.0'
gem "capistrano-bundler", "~> 1.1.0"
gem "capistrano-rails", "~> 1.1.0"
end
# Use debugger
# gem 'debugger', group: [:development, :test]
And here if my production.rb:
Example::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = false
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Generate digests for assets URLs.
config.assets.digest = true
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Set to :debug to see everything in the log.
config.log_level = :info
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# config.assets.precompile += %w( search.js )
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# For devise
config.action_mailer.default_url_options = { :host => 'example.com' }
end
I figured out the problem. i18n gem version 0.6.10 was yanked, but I was using that in my system. As soon as I rolled back to 0.6.9 everything worked fine.

FactoryGirl on Heroku : Trait not registered

Have factory_girl_rails gem installed, runs fine on local environment, but not on Heroku. It says:
Factory not registered :user.
Any ideas or relevant files I should post for help?
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.0.2'
gem 'jbuilder', '~> 1.2'
gem 'jquery-rails'
gem 'turbolinks'
gem 'uglifier', '>= 1.3.0'
# server and database stacks
gem 'pg'
gem 'rails_12factor', group: :production
gem 'thin'
# template and assets stacks
gem 'bootstrap-sass'
gem 'gon'
gem 'jquery-ui-rails'
gem 'sass-rails', '~> 4.0.0'
gem 'slim-rails'
gem 'coffee-rails', '~> 4.0.0'
gem "filepicker-rails", "~> 1.0.0"
gem 'simple_form'
# authentication and authorization stacks
gem 'devise'
gem 'role_model'
# functionality stacks
gem 'state_machine'
gem 'watu_table_builder', :require => 'table_builder'
gem 'factory_girl_rails'
gem 'faker'
group :development do
gem "better_errors"
gem "binding_of_caller"
gem 'pry-rails'
gem 'quiet_assets'
end
group :development, :test do
gem 'coveralls', require: false
gem 'dotenv-rails'
gem 'rspec-rails'
gem 'guard-rspec'
gem 'rb-fchange', require: false
gem 'rb-fsevent', require: false # For Guard file detection on Mac OS X
gem 'rb-inotify', require: false
gem 'rb-readline', require: false
end
group :test do
gem 'capybara'
gem "codeclimate-test-reporter", require: nil
gem 'database_cleaner'
gem 'shoulda-matchers'
gem 'simplecov', require: false
gem 'terminal-notifier-guard' # OSX 10.8
end
group :doc do
gem 'sdoc', require: false
end
and the application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)
module ApplicationNew
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
config.time_zone = 'Singapore'
config.active_record.default_timezone = :local
config.filepicker_rails.api_key = ENV["FILEPICKER_API_KEY"]
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.i18n.enforce_available_locales = true
config.generators do |g|
g.stylesheets false
g.helper false
g.javascripts false
g.jbuilder false
g.view_specs false
end
config.autoload_paths += Dir[Rails.root.join('app', 'models', '{**/}')]
end
end
and production.rb
ApplicationNew::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both thread web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable Rails's static asset server (Apache or nginx will already do this).
config.serve_static_assets = false
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Generate digests for assets URLs.
config.assets.digest = true
# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Set to :debug to see everything in the log.
config.log_level = :info
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = "http://assets.example.com"
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# config.assets.precompile += %w( search.js )
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Disable automatic flushing of the log to improve performance.
# config.autoflush_log = false
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
end
It's generally not the best idea to use factory girl in a staging or production environment even just to seed the database. Typically you would include the gem in the test and development groups only so it wouldn't even be installed as part of your heroku deploy.
Great blog post on why this isn't a good idea:
http://robots.thoughtbot.com/factory_girl-for-seed-data

asset pipeline not working on production, tried everythign

I have a rails 3.2 app on heroku. I have tried everything I can find to try to fix the fact that the javascripts are not loading in production mode. Everything works fine in dev though. Also, when deploying to heroku, the precompiling fails. However, when I look at the source code in prod, I can clearly see the javascripts file (/assets/application-32fdbd115c5d59c7be2876c103063600.js) loading and has content.
I have tried every setting I can think of and have read about. I am not quite sure what to do. Here's my setup currently in production.rb:
config.cache_classes = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = false
config.assets.compress = false
config.assets.compile = true
config.assets.digest = true
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
and in environment.rb:
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
App::Application.initialize!
application.rb:
require File.expand_path('../boot', __FILE__)
require "rails/all"
if defined?(Bundler)
# 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)
end
module App
class Application < Rails::Application
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true
config.active_record.whitelist_attributes = true
# 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'
and my gemfile:
gem 'rails', '3.2.6'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'pg'
gem 'mysql2'
gem 'thin'
gem 'activerecord-postgresql-adapter'
gem 'devise'
gem 'paperclip', '~> 3.0'
gem 'haml'
gem 'activeadmin'
gem "meta_search", '>= 1.1.0.pre'
gem 'aws-sdk', '~> 1.3.4'
gem 'acts_as_list'
gem 'stripe'
gem 'sass-rails', '~> 3.2.3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'coffee-rails', '~> 3.2.1'
gem 'twitter-bootstrap-rails'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :development do
gem 'debugger'
end
nothing I do seems to get it to work on production mode on my local machine or on heroku. however, it works just fine in development.
I finally figured out how to fix this, although I don't know how good of a fix it is. Basically, the problem was that the compression of the .js files into application.js was causing issues. In production.rb I put this:
config.serve_static_assets = false
# Compress JavaScripts and CSS
config.assets.compress = false
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
# Generate digests for assets URLs
config.assets.digest = true
config.assets.debug = true
this fixed the issue. however, now instead of application.js, it lists all the asset files. i'm not sure if there are any long-term issues with this.
On your production box have you tried: RAILS_ENV rake assets:precompile

Resources