rake db:migrate issue on heroku - ruby

I am following Ruby on Rails tutorial
and once I have pushed all my code to Github, I tried to deploy on Heroku using following commands -
$ heroku create
$ git push heroku master
$ heroku run rake db:migrate
I am getting following error
Running `rake db:migrate` attached to terminal... failed
! App not found
If I try to access my app I get Page does not exist. Following is my Gemfile
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.4'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
I've tried some of the other solutions for the similar questions posted here, but none of them resolved my issue.
heroku run rake db:migrate --app <app-name>
heroku pg:reset DATABASE
heroku run:detached rake db:migrate
Ruby - 2.0.0
Rails - 4.0.4
OS - Mac OSX Maverick

Related

Heroku assets are not loading and seems assets are out of date

I am having an issue where images on my Heroku production site are not being found. I have tracked it down to the digest being different in the file system from what it is looking for in the app. For example, in the logs I see the following errors:
app[web.1]: Started GET "/assets/nfl_teams/nfcn/chi-6317d0375db3876a5057f2da59bab1dc.jpeg" for 24.55.52.101 at 2016-09-08 23:10:18 +0000
app[web.1]: ActionController::RoutingError (No route matches [GET] "/assets/nfl_teams/nfcn/chi-6317d0375db3876a5057f2da59bab1dc.jpeg"):
app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
app[web.1]: vendor/bundle/ruby/2.2.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
app[web.1]: vendor/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/rack/logger.rb:38:in `call_app'
And when I go to the Heroku console and look up the asset using asset_path() I get the following:
$ heroku run rails console
Running rails console on ⬢ fbpm... up, run.7463
Loading production environment (Rails 4.2.5)
irb(main):001:0> puts helper.asset_path("nfl_teams/nfcn/chi.jpg")
/assets/nfl_teams/nfcn/chi-93d8c8c53ac98c60f7f3fee1fade067dfa9489b24b8fa4bb9fedd4b12da129de.jpg
=> nil
irb(main):002:0>
and finally looking at the heroku bash and checking the file in the directory I get:
$ heroku run bash
Running bash on ⬢ fbpm... up, run.7321
cd public~ $ cd public/assets/nfl_teams/nfcn
~/public/assets/nfl_teams/nfcn $ ls chi*.jpg
chi-93d8c8c53ac98c60f7f3fee1fade067dfa9489b24b8fa4bb9fedd4b12da129de.jpg
~/public/assets/nfl_teams/nfcn $
So, in the console looking at the asset path I get the following file:
/assets/nfl_teams/nfcn/chi-93d8c8c53ac98c60f7f3fee1fade067dfa9489b24b8fa4bb9fedd4b12da129de.jpg
And I get the same file when I look in the directory structure. Yet for some reason the application is looking for this file:
/assets/nfl_teams/nfcn/chi-6317d0375db3876a5057f2da59bab1dc.jpeg
Which doesn't exist and throws a routing error.
Here is my Gemfile:
source 'https://rubygems.org'
ruby '2.2.4'
#ruby-gemset=Rails_fb
gem 'rails','4.2.5'
gem 'bcrypt', '3.1.11'
gem 'annotate'
gem 'faker', '1.6.3'
gem 'select2-rails'
gem 'simple_form', '3.1.1'
gem 'cocoon'
#
# Bootstrap support gems
#
gem 'bootstrap-sass'
gem 'bootstrap-will_paginate', '0.0.10'
gem 'font-awesome-sass', '4.6.2'
gem 'font-awesome-rails'
gem 'sass-rails', '~> 5.0.4'
#gem 'select2-sass-bootstrap-rails'
# The following Gem is used to parse the NFL page for schedules to build
# a season.
gem 'nokogiri'
# Database. Using the same database for production/development
gem 'pg'
group :development, :test do
gem 'rspec-rails', '~>3.0'
gem 'factory_girl_rails', '4.7.0'
gem 'capybara', '2.7.1'
gem 'database_cleaner'
gem 'guard-rspec', '~> 4.2'
gem 'spork-rails'
gem 'guard-spork'
gem 'childprocess', '0.5.8'
gem 'letter_opener_web', '~>1.2.0'
end
group :test do
gem 'pry'
gem 'selenium-webdriver', '2.53.0'
gem 'libnotify', '0.9.1'
end
gem 'uglifier', '2.7.2'
gem 'coffee-rails', '4.1.1'
gem 'jquery-rails', '3.1.4'
gem 'jquery-turbolinks', '2.1.0'
gem 'turbolinks', '2.5.3'
gem 'jbuilder', '2.4.1'
group :doc do
gem 'sdoc', '0.4.1', require: false
end
group :production do
gem 'rails_12factor'
end
# To use debugger
# gem 'debugger'
gem 'execjs'
gem 'therubyracer', :platforms => :ruby
And here is the code I'm using to access the images in my views(I've tried it both with and without the asset_path() call):
<%= image_tag(asset_path(team.imagePath), size: "40") %>
Can anyone tell me why the app is looking for the wrong file? Obviously there is some disconnect in the asset pipeline but I can't figure where?
And this problem started after I upgraded from Ruby 2.0.0 to Ruby 2.2.4 which caused me to update a number of my Gems.
Hopefully this helps. In order to force a new precompile of assets on Heroku in Rails 4 you need to do the following:
rake assets:clobber
Rake assets:precompile
Then git commit/push to master and push to Heroku and it should do a new precompile that hopefully will sync up the asset pipeline. Don't use rake assets:clean as it doesn't force a new compile.

Heroku running migration rails4 and jruby

I am using rails4 with jruby.
After I successfully push to heroku, my app is running. Next I needed to run the migration and I did
$ heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.3257
stty: stdin isn't a terminal
stty: stdin isn't a terminal never fades and migration never run.
Here is my gemfile
source 'https://rubygems.org'
ruby '1.9.3', engine: "jruby", engine_version: "1.7.6"
gem 'rails', "4.0.0"
group :assets do
gem 'sass-rails'
gem 'coffee-rails'
end
group :development do
gem 'jdbc-sqlite3'
gem 'activerecord-jdbc-adapter'
end
group :production do
gem 'activerecord-jdbcpostgresql-adapter'
gem 'rails_12factor'
end
gem 'jquery-rails'
gem 'bootstrap-sass', '~> 2.3.2.2'
gem 'cancan'
gem 'devise'
gem 'figaro'
gem 'rolify', git: "https://github.com/EppO/rolify.git"
gem 'simple_form'
gem 'stripe'
gem 'stripe_event'
gem 'puma'
gem 'slim-rails'
gem 'protected_attributes'
group :development, :test do
gem 'factory_girl_rails'
gem 'rspec-rails'
end
group :test do
gem 'capybara'
gem 'cucumber-rails', :require=>false
gem 'database_cleaner', '1.0.1'
gem 'email_spec'
gem 'launchy'
end
How to run migration now? Also environment variables are not picked up by the application.
have you tried using the jruby build pack?
https://github.com/jruby/heroku-buildpack-jruby
https://devcenter.heroku.com/articles/buildpacks

rake aborted! undefined method `setup' for ActiveAdmin:Module

I have installed active admin on my development machine and it works fine.
But when i run heroku run rake db:migrate it gives me following error
rake aborted! undefined method `setup' for ActiveAdmin:Module
here is my gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.6'
gem 'pg'
gem 'haml'
gem 'haml-rails'
gem 'sorcery'#, "~> 0.7.12"
gem 'jquery-rails'
gem 'localeapp'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem "activeadmin", :git => "git://github.com/gregbell/active_admin.git"
gem 'sass-rails'#, '~> 3.2.5'
gem 'coffee-rails'#, '~> 3.2.2'
gem 'twitter-bootstrap-rails'
gem 'uglifier'
end
group :production do
gem 'thin'
end
gem "activeadmin", :git => "git://github.com/gregbell/active_admin.git"
Don't declare active admin under any group.
Atleast it wont work in production environment.
For the record, I wanted to try activeadmin-cms 0.1.0 and I had the same problem.
The gem activeadmin-cms is not compatible with activeadmin 0.6.0 (I have not tested other version of activeadmin)

cannot load --faker for heroku installation

I am trying to run heroku rake db:migrate and keep running into the same problem. It says it cannot load a file --faker. I tried putting this in my gem file in every possible way. Here's my gem file right now:
source 'http://rubygems.org'
gem 'rails', '3.0.0'
gem 'faker', '0.3.1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3-ruby', '1.2.5', :require => 'sqlite3'
gem 'gravatar_image_tag', '0.1.0'
gem 'will_paginate', '3.0.pre2'
group :development do
gem 'rspec-rails', '2.0.1'
gem 'annotate-models', '1.0.4'
end
group :test do
gem 'rspec', '2.0.1'
gem 'webrat', '0.7.1'
gem 'autotest-fsevent', '0.2.4'
gem 'autotest-growl', '0.2.9'
gem 'autotest', '4.3.2'
gem 'autotest-rails-pure', '4.1.0'
gem 'spork', '0.8.4'
gem 'factory_girl_rails', '1.0'
end
no matter what I do it won't load the faker file so I can complete the heroku install.
do you need to use faker on Heroku? Isn't it more for loading data during development? Did you try putting it in your development group?
Also, take a look at this post heroku rake db:migrate > no such file to load -- faker

Problems with sprockets when deploying Rails 3.1.rc4

I'm sure that I am just overlooking something simple here but this has been driving me crazy all night! When trying to deploy a Rails 3.1.rc4 application to the Cedar stack on Heroku (I did this successfully a month ago with a similar Gemfile) I am receiving this error:
Could not find sprockets-2.0.0.beta.10 in any of the sources
My Gemfile looks like this:
source 'http://rubygems.org'
# Core
gem 'rails', '3.1.0.rc4'
# Asset template engines
gem 'sass-rails', "~> 3.1.0.rc"
gem 'coffee-script'
gem 'uglifier'
# Misc
gem 'devise'
gem 'jquery-rails'
gem 'omniauth'
gem 'fb_graph'
gem 'compass', git: 'https://github.com/chriseppstein/compass.git', branch: 'rails31'
gem 'haml'
gem 'cancan'
gem 'kaminari'
gem 'friendly_id', '~> 3.3.0', git: 'https://github.com/norman/friendly_id.git'
gem 'recaptcha', :require => 'recaptcha/rails'
gem 'aws-ses', '~> 0.4.3', :require => 'aws/ses'
# Local Environment
group :test do
# Pretty printed test output
gem 'turn', :require => false
gem 'sqlite3'
end
# Heroku Environment
group :production do
gem 'pg'
gem 'execjs'
gem 'therubyracer'
end
After searching around and finding this article on Google Groups, I determined that this must be fixable by adding this line
gem 'sprockets', '2.0.0.beta10'
to my Gemfile and then running
bundle update sprockets
This failed with
Could not find gem 'sprockets (= 2.0.0.beta10, runtime)' in any of the gem sources listed in your Gemfile.
and at this point I don't know what to do or how to handle this. Is it possible that I need to upgrade to Rails 3.1.rc5 and if so how may I do that without starting over from scratch?
Thank you for any help that you can provide!
-Robert
Just bump your rails version up to rc5
gem 'rails', '3.1.0rc5'
then:
bundle update

Resources