deploy rails mongo app to heroku

669 views Asked by At

I'm having issues to push my Rails app to Heroku. When I try to log in in diabetes-app.herokuapp.com the browser tells me that something went wrong and if I do heroku logs in console it gives me a complete track information but I don't get what is wrong. At the end it says 'Slug compilation failed: failed to compile Ruby app'. I think it should have something to do with the Rails assets pipeline because if i do git push heroku master everything goes well untill it starts to prepare the app for Rails asset pipeline. Observe from the line that says remote: -----> Preparing app for Rails asset pipeline I know it's not easy to solve the problem just with this information but a little hint of where could be the origin of the issue would be great.

This is the trace of doing Git push heroku master

remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.1.3
remote: -----> Installing dependencies using 1.9.7
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Fetching gem metadata from https://rubygems.org/...........
remote:        Fetching version metadata from https://rubygems.org/...
remote:        Fetching dependency metadata from https://rubygems.org/..
remote:        Using i18n 0.6.11
remote:        Using json 1.8.1
remote:        Using rake 10.4.2
remote:        Using minitest 5.5.0
remote:        Using thread_safe 0.3.4
remote:        Using builder 3.2.2
remote:        Using erubis 2.7.0
remote:        Using rack 1.5.2
remote:        Using mime-types 2.4.3
remote:        Using arel 5.0.1.20140414130214
remote:        Using bcrypt 3.1.9
remote:        Using coffee-script-source 1.8.0
remote:        Using execjs 2.2.2
remote:        Using thor 0.19.1
remote:        Using orm_adapter 0.5.0
remote:        Using multi_json 1.10.1
remote:        Using request_store 1.1.0
remote:        Using hike 1.2.3
remote:        Installing optionable 0.2.0
remote:        Installing connection_pool 2.1.2
remote:        Using bundler 1.9.7
remote:        Using tilt 1.4.1
remote:        Using rails_serve_static_assets 0.0.2
remote:        Using rails_stdout_logging 0.0.3
remote:        Using sass 3.2.19
remote:        Using tzinfo 1.2.2
remote:        Using rack-test 0.6.2
remote:        Using warden 1.2.3
remote:        Using mail 2.6.3
remote:        Using coffee-script 2.3.0
remote:        Using uglifier 2.6.0
remote:        Using sprockets 2.12.3
remote:        Using rails_12factor 0.0.3
remote:        Using activesupport 4.1.7
remote:        Using actionview 4.1.7
remote:        Using activemodel 4.1.7
remote:        Using jbuilder 2.2.6
remote:        Using actionpack 4.1.7
remote:        Using activerecord 4.1.7
remote:        Using actionmailer 4.1.7
remote:        Using railties 4.1.7
remote:        Using gon 5.2.3
remote:        Using sprockets-rails 2.2.2
remote:        Using coffee-rails 4.1.0
remote:        Installing origin 2.1.1
remote:        Using responders 1.1.2
remote:        Using jquery-rails 3.1.2
remote:        Using rails 4.1.7
remote:        Using sass-rails 4.0.5
remote:        Using turbolinks 2.5.3
remote:        Using devise 3.4.1
remote:        Installing d3-rails 3.5.5
remote:        Installing bson 2.3.0
remote:        Installing moped 2.0.4
remote:        Installing mongoid 4.0.2
remote:        Bundle complete! 22 Gemfile dependencies, 55 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 (10.20s)
remote:        Cleaning up the bundler cache.
remote:        Removing sdoc (0.4.1)
remote:        Removing bundler (1.6.3)
remote:        Removing rdoc (4.2.0)
remote:        Removing pg (0.17.1)
remote:        Removing friendly_id (5.0.4)
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        NoMethodError: undefined method `active_record' for #<Rails::Application::Configuration:0x007f0caba339f0>
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/railtie/configuration.rb:95:in `method_missing'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/config/environments/production.rb:77:in `block in <top (required)>'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/railtie.rb:210:in `instance_eval'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/railtie.rb:210:in `configure'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/config/environments/production.rb:1:in `<top (required)>'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:247:in `require'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:247:in `block in require'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:232:in `load_dependency'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:247:in `require'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/engine.rb:594:in `block (2 levels) in <class:Engine>'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/engine.rb:593:in `each'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/engine.rb:593:in `block in <class:Engine>'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/initializable.rb:30:in `instance_exec'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/initializable.rb:30:in `run'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/initializable.rb:55:in `block in run_initializers'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/initializable.rb:44:in `each'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/initializable.rb:44:in `tsort_each_child'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/initializable.rb:54:in `run_initializers'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/application.rb:300:in `initialize!'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/config/environment.rb:5:in `<top (required)>'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:247:in `require'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:247:in `block in require'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:232:in `load_dependency'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/activesupport-4.1.7/lib/active_support/dependencies.rb:247:in `require'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/application.rb:276:in `require_environment!'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/railties-4.1.7/lib/rails/application.rb:389:in `block in run_tasks_blocks'
remote:        /tmp/build_b2a9a111219cc7b78d5d89b4f5ea382e/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.2.2/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define'
remote:        Tasks: TOP => environment
remote:        (See full trace by running task with --trace)
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote: 
remote:  !     Push rejected, failed to compile Ruby app
remote: 
remote: Verifying deploy....
remote: 
remote: !   Push rejected to diabetes-app.
remote: 
To [email protected]:diabetes-app.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:diabetes-app.git'

And I think this is the first error displayed when I do heroku logs

ActionController::RoutingError (No route matches [GET] "/javascripts/devise/sessions.js"):

And this the last message of the full trace

2015-06-15T13:46:53.863672+00:00 heroku[slug-compiler]: Slug compilation started
2015-06-15T13:46:53.863680+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app

Edited

This is my application.rb

require File.expand_path('../boot', __FILE__)
require "action_controller/railtie"
require "action_mailer/railtie"
require "rails/test_unit/railtie"
require "sprockets/railtie"


Bundler.require(*Rails.groups)

module DiabetesApp
  class Application < Rails::Application

    config.assets.initialize_on_precompile=false

    rake assets:precompile
  end
end

And this is my config/environments/production.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 = false
  config.assets.js_compressor = :uglifier
  config.assets.compile = false
  config.log_level = :info
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
  config.log_formatter = ::Logger::Formatter.new

end

This is my gemfile

source 'https://rubygems.org'

gem 'rails', '4.1.7'
gem 'gon'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem "d3-rails"
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem "mongoid", '~> 4.0.0'
gem 'devise'

group :development, :test do
  gem 'rspec-rails', '~> 3.0'
  gem 'cucumber-rails', :require => false
  gem 'factory_girl_rails'
  gem 'database_cleaner'
  gem 'pry'
  gem 'validates_timeliness', '~> 3.0'
  gem 'timecop', '0.7.1'
  gem 'awesome_print'
  gem 'guard-rails'
end

group :test do
  gem 'shoulda-matchers', require: false
  gem "capybara-webkit"
end

group :production do
  gem 'rails_12factor'
  gem 'thin'
end
1

There are 1 answers

15
a14m On

As mentioned in the documentation in the configuration part

Open myapp/config/application.rb and near the top

remove the line require "rails/all" and add the following lines so you end up with this

require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie" # Comment this line for Rails 4.0+
require "rails/test_unit/railtie"
# require "sprockets/railtie" # Uncomment this line for Rails 3.1+