CarrierWave url nil after upgrading from Rails 3 to Rails 4 - ruby-on-rails-4

While upgrading our app from Rails 3.2.22 to Rails 4.2.11, several CarrierWave methods that worked prior to the upgrade now return nil, such as .url and .file. We are hosting our assets on AWS S3 and our app is hosted on Heroku. Strangely, the images work as expected in our dev environment.
CarrierWave 1.3.1 (upgraded from 0.11.2)
Rails 4.2.11, upgraded from 3.2.22
Ruby 2.2.5
fog-aws 3.3.0
So far I have tried changing around the carrierwave config, and playing around with different methods in the rails console and comparing the results in development with production.
Gemfile
source 'https://rubygems.org'
ruby '2.2.5'
gem 'rails', '4.2.11'
gem 'puma'
gem 'pg', '0.15.1'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'rack-cors'
gem 'sprockets_uglifier_with_source_maps'
gem 'carrierwave'
gem 'mini_magick', '3.6.0'
gem 'paper_trail', '>= 4.0'
gem 'fog-aws'
gem 'aws-sdk-s3', '~> 1'
gem 'identity_cache', '>= 0.2'
gem 'memcachier'
gem 'dalli'
gem 'connection_pool'
gem 'active_model_serializers', '>= 0.10'
gem 'formtastic', '~> 3.1.0'
gem 'sprockets-rails', require: 'sprockets/railtie'
gem 'sprockets-image_compressor'
gem 'actionpack-action_caching'
gem 'sass-rails', '5.0.6'
gem 'uglifier', '2.5.0'
gem 'compass-rails'
gem 'sprite-factory', '1.5.3'
gem 'responders', '~> 2.0'
group :development do
gem 'rack-mini-profiler'
gem 'rmagick', '2.13.2'
end
carrierwave.rb
CarrierWave.configure do |config|
config.fog_provider = 'fog/aws'
config.fog_credentials = {
provider: ENV['FOG_PROVIDER'],
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
region: ENV['FOG_REGION'],
endpoint: ENV['FOG_HOST']
}
if Rails.env.production?
config.storage = :fog
config.fog_directory = ENV['FOG_DIRECTORY']
config.fog_public = false
config.fog_authenticated_url_expiration = 1800
else
config.asset_host = "#{ENV['FOG_HOST']}"
config.storage = :file
config.enable_processing = false if Rails.env.test?
end
end
art_uploader.rb
# encoding: utf-8
class ArtUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
version :thumbnail do
process resize_to_fill: [100, 100]
end
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Add a white list of extensions which are allowed to be uploaded.
def extension_white_list
%w(jpg jpeg png)
end
# Provide a default URL as a default if there hasn't been a file uploaded:
def default_url
if model.has_fallback_art?
version_name == :thumbnail
model.song.artist.photo.small_thumb.url :
model.song.artist.photo.album_art.url
end
end
end
I expect to be able to return the asset path from S3 when I enter
art.url
In development I get art.url => "https://qa-marmosetmusic-com.s3.amazonaws.com/uploads/artist/photo/173/af2ac015-1d44-4481-b5d6-5bf5cb8c0e23.jpg"
However in prodution art.url => nil.
When I enter art in the development console, it returns this object:
=> #<ArtUploader::Uploader70128841541160:0x007f904c7c88f8
#cache_id=nil,
#file=
#<CarrierWave::SanitizedFile:0x007f904c1ffd68
#content=nil,
#content_type=nil,
#file=
"/Users/ekingan/dev/marmoset/public/uploads/album/art/3540/thumbnail_Evan_Andree_Your_Heart_Album_Artwork_1_3000x3000.jpg",
#original_filename=nil>,
#filename=nil,
#format=nil,
#model=
#<Album:0x007f904a0417a8
id: 3540,
title: "Your Heart",
art: "Evan_Andree_Your_Heart_Album_Artwork_1_3000x3000.jpg",
state: "active",
description: "",
created_at: Tue, 27 Nov 2018 12:50:14 PST -08:00,
updated_at: Tue, 27 Nov 2018 12:50:14 PST -08:00>,
#mounted_as=:art,
#parent_version=
#<ArtUploader:0x007f904c7c9618
#cache_id=nil,
#file=
#<CarrierWave::SanitizedFile:0x007f904c7c8948
#content=nil,
#content_type=nil,
#file="/Users/ekingan/dev/marmoset/public/uploads/album/art/3540/Evan_Andree_Your_Heart_Album_Artwork_1_3000x3000.jpg",
#original_filename=nil>,
#filename=nil,
#format=nil,
#model=
#<Album:0x007f904a0417a8
id: 3540,
title: "Your Heart",
art: "Evan_Andree_Your_Heart_Album_Artwork_1_3000x3000.jpg",
state: "active",
description: "",
created_at: Tue, 27 Nov 2018 12:50:14 PST -08:00,
updated_at: Tue, 27 Nov 2018 12:50:14 PST -08:00>,
#mounted_as=:art,
#storage=#<CarrierWave::Storage::File:0x007f904c7c9118 #cache_called=nil, #uploader=#<ArtUploader:0x007f904c7c9618 ...>>,
#versions={:thumbnail=>#<ArtUploader::Uploader70128841541160:0x007f904c7c88f8 ...>}>,
#storage=
#<CarrierWave::Storage::File:0x007f904c7c86f0
#cache_called=nil,
#uploader=#<ArtUploader::Uploader70128841541160:0x007f904c7c88f8 ...>>,
#versions={}>
When I enter the same in production it returns:
#<ArtUploader::Uploader6168740:0x000000072781c8 #model=#<Album id: 2008, title: "Vektlaus", art: "Daniel+Kvammen+-+Vektlaus.jpg", state: "active", description: nil, created_at: "2017-05-19 18:40:43", updated_at: "2017-07-26 16:51:17">, #mounted_as=:art, #file=nil, #filename=nil, #cache_id=nil, #versions={}, #format=nil, #parent_version=#<ArtUploader:0x00000007278d30 #model=#<Album id: 2008, title: "Vektlaus", art: "Daniel+Kvammen+-+Vektlaus.jpg", state: "active", description: nil, created_at: "2017-05-19 18:40:43", updated_at: "2017-07-26 16:51:17">, #mounted_as=:art, #file=nil, #filename=nil, #cache_id=nil, #versions={:thumbnail=>#<ArtUploader::Uploader6168740:0x000000072781c8 ...>}, #format=nil, #storage=#<CarrierWave::Storage::Fog:0x000000072786f0 #uploader=#<ArtUploader:0x00000007278d30 ...>>>, #storage=#<CarrierWave::Storage::Fog:0x00000007267300 #uploader=#<ArtUploader::Uploader6168740:0x000000072781c8 ...>>>
I would love to hear any suggestions.
Thanks!

We resolved this!
We had a file in carrierwave/storage called fog.rb that was overriding the gem behavior and causing this issue. Removing that file allowed everything to work as intended.

Related

Ruby on Rails - Small activerecord and view rendering time yet big response time

I have a Ruby on Rails application that is working fine for most of the API requests but for some API requests it just hangs. ActiveRecord queries are made in small time and also view is rendered in small time as well but yet response time is very big.
Rails version is 4.2.5 and Ruby version is 2.2.0, Database that I am using is Postgresql. Below I am attaching my Gemfile and also production log and also the code for which this is happening.
Production.log
I, [2019-09-07T09:23:45.748270 #22745] INFO -- : Started GET "/api/v3/restaurants/1/accepted_orders?skip_search=1" for
165.228.89.233 at 2019-09-07 09:23:45 +0000
I, [2019-09-07T09:23:45.753331 #22745] INFO -- : Processing by Api::V3::Staff::OrdersController#accepted_index as JSON
I, [2019-09-07T09:23:45.753387 #22745] INFO -- : Parameters: {"skip_search"=>"1", "id"=>"1"}
D, [2019-09-07T09:23:45.756807 #22745] DEBUG -- : User Load (2.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 6]]
D, [2019-09-07T09:23:45.761643 #22745] DEBUG -- : User Load (3.9ms) SELECT "users".* FROM "users" WHERE "users"."uid" = $1 LIMIT 1 [["uid", "example#gmail.com"]]
D, [2019-09-07T09:23:45.765724 #22745] DEBUG -- : Eula Load (3.1ms) SELECT "eulas".* FROM "eulas" WHERE "eulas"."is_latest" = $1 LIMIT 1 [["is_latest", "t"]]
D, [2019-09-07T09:23:45.768793 #22745] DEBUG -- : Privacy Load (2.7ms) SELECT "privacies".* FROM "privacies" WHERE "privacies"."is_latest" = $1 LIMIT 1 [["is_latest", "t"]]
D, [2019-09-07T09:23:45.772602#22745] DEBUG -- : Restaurant Load (3.0ms) SELECT "restaurants".* FROM "restaurants" WHERE "restaurants"."id" = $1 LIMIT 1 [["id", 1]]
D, [2019-09-07T09:23:46.293350 #22745] DEBUG -- : Order Load (519.6ms) SELECT "orders".* FROM "orders" WHERE "orders"."restaurant_id" IN (1)
D, [2019-09-07T10:44:50.564263 #22745] DEBUG -- : (19.8ms) SELECT COUNT(*) FROM "orders" WHERE "orders"."status" = $1 AND "orders"."restaurant_id" = 1 AND ( DATE(orders.created_at) >= '2019-09-07 09:45:50 UTC') [["status", 1]]
D, [2019-09-07T10:44:50.577108 #22745] DEBUG -- : (11.7ms) SELECT COUNT(*) FROM "orders" WHERE "orders"."status" = $1 AND "orders"."restaurant_id" = 1 AND ( DATE(orders.created_at) >= '2019-09-07 09:45:50 UTC') [["status", 0]]
D, [2019-09-07T10:44:50.580691 #22745] DEBUG -- : User Exists (1.5ms) SELECT 1 AS one FROM "users" WHERE ("users"."email" = 'example#gmail.com' AND "users"."id" != 6) LIMIT 1
D, [2019-09-07T10:44:50.582116 #22745] DEBUG -- : User Exists (0.6ms) SELECT 1 AS one FROM "users" WHERE ("users"."username" = 'Staff 1' AND "users"."id" != 6) LIMIT 1
D, [2019-09-07T10:44:50.584594#22745] DEBUG -- : User Exists (1.8ms) SELECT 1 AS one FROM "users" WHERE ("users"."phone_number" = '+777777777' AND "users"."id" != 6) LIMIT 1
I, [2019-09-07T10:44:50.586265 #22745] INFO -- : Completed 200 OK in 4864833ms (Views: 0.3ms | ActiveRecord:
570.2ms)
Part of code having the error
api :GET, '/v3/restaurants/:id/accepted_orders', 'Returns all accepted orders of a restaurant (for staff and owners)'
param :id, String, desc: 'id of the restaurant', required: true
def accepted_index
query = " DATE(orders.created_at) >= '#{59.minutes.ago}'" if current_user.staff?
accepted = Order.where(status: Order.statuses[:accepted], restaurant: #restaurant).where(query)
pending = Order.where(status: Order.statuses[:pending], restaurant: #restaurant).where(query)
render json: {accepted_count: accepted.count, pending_count: pending.count}
end
Gemfile
source 'https://rubygems.org'
ruby '2.2.0'
gem 'rails', '4.2.5'
gem 'pg'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
gem 'annotate'
gem 'activeadmin', github: 'activeadmin'
gem 'paper_trail', '~> 4.0.0'
gem 'dotenv-rails'
# MailChimp integration
gem 'gibbon'
gem 'google_directions'
gem 'geocoder'
gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby'
# The push notification service.
gem 'rpush', github: 'rpush/rpush'
gem 'prawn-rails'
gem 'prawn-table'
gem 'active_admin_datetimepicker'
gem 'phony_rails'
gem 'closure_tree'
gem 'whenever', require: false
group :development, :test do
gem 'byebug'
end
group :development do
gem 'pry'
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'letter_opener'
end
gem 'apipie-rails'
gem 'devise'
gem 'high_voltage'
gem 'simple_form'
gem 'rack-cors', :require => 'rack/cors'
gem 'omniauth'
gem 'devise_token_auth'
gem 'sidekiq', '~> 4.0', '>= 4.0.1'
# gem 'ckeditor', '~> 4.1', '>= 4.1.5'
gem 'socket.io-client-simple'
gem 'houston'
gem 'fancybox-rails', '~> 0.3.0'
gem 'mini_magick', '~> 4.3', '>= 4.3.6'
gem 'carrierwave', '~> 0.10.0'
gem 'fog', '~> 1.36'
gem 'chosen-rails'
gem 'twilio-ruby', '~> 4.11.1'
group :development do
gem 'better_errors'
gem 'quiet_assets'
gem 'rails_layout'
gem 'spring-commands-rspec'
gem 'capistrano', '~> 3.1.0'
gem 'capistrano-bundler', '~> 1.1.2'
gem 'capistrano-rails', '~> 1.1.1'
gem 'capistrano-rvm', github: "capistrano/rvm"
gem 'capistrano-sidekiq'
gem 'rest-client'
end
group :development, :test do
gem 'factory_girl_rails'
gem 'faker'
gem 'rspec'
gem 'fakeredis'
gem 'rspec-rails'
gem 'shoulda-matchers', '~> 3.0'
gem 'shoulda-callback-matchers', '~> 1.1.1'
gem 'redis-namespace'
end
group :test do
gem 'capybara'
gem 'database_cleaner'
gem 'launchy'
gem 'selenium-webdriver'
end
gem 'sinatra', :require => nil
On production server I am using nginx and Passenger.
Thanks

Getting uninitialized constant Student::Roo error while importing csv file in rails

I have an application on which I want to provide the feature to import the records from CSV and Excel file formats. I am using roo gem for it, but at the time of importing it gives the error "uninitialized constant Student::Roo".
Here is the code :
student.rb
def self.import(file)
spreadsheet = open_spreadsheet(file)
header = spreadsheet.row(1)
(2..spreadsheet.last_row).each do |i|
row = Hash[[header, spreadsheet.row(i)].transpose]
product = find_by_id(row["id"]) || new
product.attributes = row.to_hash.slice(*accessible_attributes)
product.save!
end
end
def self.open_spreadsheet(file)
case File.extname(file.original_filename)
when ".csv" then Roo::Csv.new(file.path, nil, :ignore)
when ".xls" then Roo::Excel.new(file.path, nil, :ignore)
when ".xlsx" then Roo::Excelx.new(file.path, nil, :ignore)
else raise "Unknown file type: #{file.original_filename}"
end
end
student_controller.rb :
def import
Student.import(params[:file])
#puts #session[:current_organization_id].inspect
redirect_to students_path, notice: "Record imported Successfully."
end
new.html.erb :
<%= form_tag import_students_path, multipart: true do %>
<%= file_field_tag :file , :required=> true%> <br/>
<%= submit_tag "Import" , :class => "btn btn-primary btn-block" %>
<% end %>
Gemfile :
source 'https://rubygems.org'
gem 'rails', '4.2.0'
gem 'mysql2'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'sass', '3.2.19'
gem 'bower-rails'
gem 'font-awesome-sass'
gem 'devise'
gem 'roo'
group :development, :test do
gem "rspec-rails", "~> 2.0"
gem "factory_girl_rails", "~> 4.0"
gem "capybara"
gem "database_cleaner"
gem "selenium-webdriver"
end
student.csv : This is the test data for student.
enrollment_no,roll_no,address,father_name
11,21,test,test
17,21,test,test
18,21,test,test
19,21,test,test
20,21,test,test
22,21,test,test
23,21,test,test
24,21,test,test
It's not Roo::Csv, it's Roo::CSV. So the code should like
def self.open_spreadsheet(file)
case File.extname(file.original_filename)
when ".csv" then Roo::CSV.new(file.path, nil, :ignore)
when ".xls" then Roo::Excel.new(file.path, nil, :ignore)
when ".xlsx" then Roo::Excelx.new(file.path, nil, :ignore)
else raise "Unknown file type: #{file.original_filename}"
end
end
btw, no need to do require 'roo'
First, after #SKV comment: the correct name for CSV class is Roo::CSV and not Roo::Csv.
If the error persists, then it means that any of the Roo classes (Roo::CSV, Roo::Excel, etc) is not defined at this point in Student class. This probably means that, while you probably added the roo gem to your Gemfile and bundled, you need to require roo wherever you want to use the gem. This is mentioned in the gem docs.
Add require 'roo' to the top of student.rb file and it should work fine:
# student.rb
require 'roo' # <====
class Student < ActiveRecord::Base
def self.open_spreadsheet(file)
...
end
end

(Rails) : NoMethodError: undefined method cost' for BCrypt::Engine:Class

When I learn "Ruby on Rails Tutorial", and I want to create a User on console:
irb(main):001:0> User.create(name:"gsky",email:"k#q.com",
irb(main):002:1* password:"aaaaaa",password_confirmation:"aaaaaa")
then, I getting the following error message:
NoMethodError: undefined method cost' for BCrypt::Engine:Class
from D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activemodel-4.
0.2/lib/active_model/secure_password.rb:104:inpassword='
from D:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/activerecord-4
.0.2/lib/active_record/attribute_assignment.rb:42:in public_send'
This is user model:
class User < ActiveRecord::Base
before_save { self.email = email.downcase }
validates :name, presence: true, length: { maximum: 50 }
VALID_EMAIL_REGEX = /\A[\w+\-.]+#[a-z\d\-.]+\.[a-z]+\z/i
validates :email, presence: true,
format: { with: VALID_EMAIL_REGEX },
uniqueness: { case_sensitive: false }
has_secure_password
validates :password, length: { minimum: 6 }
end
Add bcrypt-ruby to your Gemfile as specified below:
gem 'bcrypt-ruby', '3.1.2'
then run bundle update from your project root directory and bundle install
When i saw "Ruby On Rails Tutorial" I have met the same problem,
I solved it by set Gemfile from:
gem 'bcrypt-ruby', '3.0.1'
to:
gem 'bcrypt-ruby', '3.1.2'
then run:
bundle install
Also going for the tutorial/book and having the same problems, I used gem 'bcrypt-ruby', '~> 3.0.0' because of problems with bundle install. After going through secure_password.rb, the problem was in BCrypt::Engine.cost, this method actually doesn't exist.
I changed my gem to gem 'bcrypt-ruby', '~> 3.1.0' which installed bcrypt 3.1.7. Saw a warning message about the gem being renamed and changed it to gem 'bcrypt', '~> 3.1.0' (this part shouldn't matter). After doing bundle install, I was able to see the implementation of Bcrypt::Engine.cost through my IDE and I was able to make my user in rails c.
I want to add that adding ActiveModel::SecurePassword.min_cost = true in test.rb was able to let me make new users if I ran rails c in test environment, but when I added the same line in development.rb, it didn't work.
I think you are learning rails from the tutorial. If you just want to continue and not spent much time on doing the right fix, you can just use the cost as say 10, instead of calling the BCrypt::Engine.cost method.
So replace
cost = BCrypt::Engine.cost
with
cost = 10
This value when used will take less than 200ms to compute and that should be okay.
Tested on mac:
Include this in your gemfile:
gem 'bcrypt', '3.1.11'
run:
xcode-select --install
then run: bundle install
That's it.
Best of lucks

Prawn in a Ruby on Rails app, failing on production

I am stuck on an issue with running prawn in production.
I have followed the Railscast (revised http://railscasts.com/episodes/153-pdfs-with-prawn-revised?view=asciicast) pretty much to the letter. It works great in my development environment (Mac OS X 10.9.1) but causes unicorn to falter on my server. My production server is (Redhat => Red Hat Enterprise Linux Server release 6.4 (Santiago)). I have the gem installed via Gemfile.
Gemfile:
gem 'prawn'
gem 'prawn-qrcode'
Controller: (show action)
def show
##classroom = Classroom.find(params[:id])
#classroom = find_classroom
#page_title = #classroom.location.name
#classroom_alt = #classroom.location.name + " - " + #classroom.room_number
#building = find_building(#classroom.location_id)
#owner = Owner.find(#classroom.owner_id)
#room_schedule_contact = RoomScheduleContact.find_by rmrecnbr:(#classroom.rmrecnbr)
#building_image = #building.picture.url(:medium).to_s
#building_sign_image = #building.building_sign.url(:thumb).to_s
#search = Classroom.search(params[:search])
##classroom_herprod = Building.find(params[:location_id]).building_short_code
respond_to do |format|
format.html # show.html.erb
format.png { render :qrcode => "http://rooms.lsa.umich.edu/classrooms/#{#classroom.facility_code_heprod}", :level => :l, :unit => 8 }
format.pdf do
pdf = ClassroomPdf.new(#classroom)
send_data pdf.render, type: "application/pdf",
disposition: "inline"
end
end
end
I have a pdfs directory with a classroom_pdf.rb file that includes the following.
class ClassroomPdf < Prawn::Document
def initialize(classroom)
super(top_margin: 70)
text "This is a pdf"
end
end
(This is stripped down from what I had, but it is the most basic version that works on my dev system and fails on production).
I am running the following
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
gem 'rails', '4.0.2'
The error in the unicorn.stderr.log is as follows.
E, [2014-02-07T12:39:20.400750 #7300] ERROR -- : reaped #<Process::Status: pid 7306 exit 1> worker=1
I, [2014-02-07T12:39:20.401257 #7300] INFO -- : worker=1 spawning...
I, [2014-02-07T12:39:20.463964 #7529] INFO -- : worker=1 spawned pid=7529
I, [2014-02-07T12:39:20.521524 #7529] INFO -- : Refreshing Gem list
E, [2014-02-07T12:39:29.938423 #7326] ERROR -- : uninitialized constant Prawn (NameError)
/var/www/rooms.lsa.umich.edu/html/iris/releases/20140207173433/app/pdfs/classroom_pdf.rb:1:in `<top (required)>'
/var/www/rooms.lsa.umich.edu/html/iris/shared/bundle/ruby/2.0.0/gems/railties-4.0.1/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
Here is the gemfile
source 'https://rubygems.org'
##gem 'rails', '3.2.14'
gem 'rails', '4.0.2'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
#gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
gem "haml"
#gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails'
gem 'bootstrap-sass', '~> 3.1.0'
#gem 'google-analytics-rails'
gem 'font-awesome-rails'
gem 'protected_attributes'
gem 'modernizr-rails'
gem "jquery-rails"
gem "devise", "3.0.3"
gem "cancan", ">= 1.6.9"
gem "rolify", ">= 3.2.0"
gem 'newrelic_rpm'
# QR-Code generation
gem 'rqrcode-rails3'
gem 'mini_magick'
gem 'prawn'
#gem 'prawn', '1.0.0.rc2'
gem 'prawn-qrcode'
#gem 'prawnto'
gem 'capistrano', '2.15.5'
#gem 'capistrano'
gem "simple_form"
gem 'will_paginate', '~> 3.0.5'
gem "therubyracer", :group => :assets, :platform => :ruby
gem 'will_paginate-bootstrap'
#gem 'kaminari'
## Used for uploading and resizing images (Need both paperclip and mini_magick)
gem "paperclip", "3.5.1"
#gem "meta_search"
gem "ransack"
gem 'annotate', ">=2.6.0"
group :production do
gem 'unicorn'
end
Any ideas?
It turns out that I needed to manually reboot unicorn for it to properly load the new gem file.

Rails 4 assets not loading in heroku after 'rake assets:precompile'

This is driving me insane! My app works properly on the local server, but when I uploaded to heroku, the css and js files didn't update. I read to precompile using rake assets:precompile to fix the issue, but then I uploaded to heroku again and now all my assets aren't loading at all! I've tried all variations of precompile, installed 12factor gem, turned some config settings from false to true, still not happening! When i look at the console, it says
[Error] ReferenceError: Can't find variable: jQuery
global code (application-38ccb09605964287831a37a0d9faf188.js, line 1)
but I do have Jquery! it works fine on local! I dunno what I'm doing wrong guys.
Gemfile
gem 'bootstrap-sass-rails'
gem 'rails_12factor', group: :production
gem 'rails', '4.0.0'
gem 'sqlite3', :group => [:development, :test]
group :production do
gem 'thin'
gem 'pg'
end
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
production.rb
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.compile = true
config.assets.digest = true
config.assets.version = '1.0'
config.log_level = :info
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
running $RAILS_ENV=production bundle exec rake assets:precompile made my heroku app work now. so i guess problem is fixed..
sorry, I don't have an explanation on why it works
Simply run
$ bundle exec rake assets:precompile
$ git add .
$ git commit -am "assets precompiled locally"
$ git push heroku master