Deploying to Rails project to Heroku: Could not find activemodel - ruby-on-rails-3

I am relatively new to rails and have been working my way through the Michael Hartl Tutorial. Throughout I have been deploying my projects to Heroku, however now I am at the end of chapter 5, I am getting an "application error". Specifically I am getting the following errors when I look into my Heroku logs:
2012-01-04T03:05:04+00:00 app[web.1]: Could not find activemodel-3.2.0.rc1 in any of the sources
2012-01-04T03:05:06+00:00 heroku[web.1]: State changed from starting to crashed
2012-01-04T03:05:06+00:00 heroku[web.1]: Process exited
2012-01-04T03:05:11+00:00 heroku[router]: Error H10 (App crashed) -> GET floating-stone 5077.heroku.com/ dyno= queue= wait= service= status=503 bytes=
Earlier in the log I see the following errors as well:
WARNING: Invalid .gemspec format in '/app/.bundle/gems/ruby/1.9.1/specifications/rails-3.2.0.rc1.gemspec'
WARNING: Invalid .gemspec format in '/app/.bundle/gems/ruby/1.9.1/specifications/actionmailer-3.2.0.rc1.gemspec'
WARNING: Invalid .gemspec format in '/app/.bundle/gems/ruby/1.9.1/specifications/actionpack-3.2.0.rc1.gemspec'
my gemfile is as follows:
source 'https://rubygems.org'
gem 'rails', '3.2.0.rc1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql2'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.0'
gem 'coffee-rails', '~> 3.2.0'
#gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :development do
gem 'rspec-rails', '2.7.0'
gem 'ZenTest', '4.6.2'
gem 'autotest-growl'
gem 'autotest-fsevent'
gem 'webrat', '0.7.3'
end
group :test do
gem 'rspec', '2.7.0'
gem 'webrat', '0.7.3'
end
I am having trouble debugging the issue and looked through almost all of the rails/heroku posts I could find but nothing on this specific issue. I was looking for some help...apologies if this is something quite basic.
I should also mention that the app works fine on my local machine and here is my database information (I am using mysql). Here is the DB info.
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: sample_app_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: mysql2
encoding: utf8
reconnect: false
database: sample_app_test
pool: 5
username: root
password:
socket: /tmp/mysql.sock
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: sample_app_production
pool: 5
username: root
password:
socket: /tmp/mysql.sock
Thanks!

The live version of new rails is available now ... i think you should give a try to rails 3.1.3 mature version ... this seem to come configuration issue as i am running my apps perfectly with rails 3.1.3 in heroku.

Does your Gemfile.lock file mention this version of ActiveModel? Have you done a full bundle update rails / bundle install, then committed the file and re-deployed?

I had this same problem. What worked in development locally, did not work when I deployed to Heroku. It is likely that you have a gem that is locked to an older version of Rails (or ActiveSupport as was my case.) Review your Gemfile.lock file. You may will likely find a reference to an older version of a Rails component.
Should you find this to be true, try commenting out the gem and see if your app will run when you deploy to Heroku. If so, then review the GitHub forks of the offending gem to see if someone has a solution. If you find an alternative, specify the git repository in your gem file and then run bundle install.
e.g.
gem 'tinymce-rails', :git => 'git://github.com/spohlenz/tinymce-rails.git'

Related

Rails can't install gem sqlite

Gem files will remain installed in
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sqlite3-1.4.0 for
inspection.
Results logged to
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/sqlite3-1.4.0/gem_make.out
An error occurred while installing sqlite3 (1.4.0), and Bundler cannot continue.
Make sure that gem install sqlite3 -v '1.4.0' succeeds before bundling.
I tried to install earlier version on sqlite, not working.
Tried one of the solutions from stackoverflow :
gem 'sqlite3', '~> 1.3.6'
getting this error
ERROR: While executing gem ... (Gem::CommandLineError)
Unknown command sqlite3,
Please help i'm new in Rails , this is my first project in rails.
Add gem 'sqlite3' to Gemfile in the root directory of your rails project. Then run bundle install and it should install sqlite and make it available to use in your rails project.
Specify git and branch for the gem sqlite3 in your Gemfile should fix the problem.
gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec"
For more info
https://medium.com/#declancronje/installing-and-troubleshooting-ruby-on-rails-sqlite3-windows-10-fix-87c8886d03b
cannot load such file — sqlite3/sqlite3_native (LoadError) Ruby on Rails
Replace gem 'sqlite3' with gem 'sqlite3', '~> 1.3.11' which is in Gemfile in the root directory of your rails project. Then run bundle install.

Ruby on Rails Passenger on Apache gemfile syntax Error ID 506682d5

Running Rails 4 on Apache2 using Phusion Passenger and Ruby 2.1 installed via RVM. When I access the Rails app in the browser, I get this error:
Gemfile syntax error compile error
on line 24: syntax error, unexpected ':', expecting $end
gem 'sdoc', '~> 0.4.0', group: :doc
^ (Bundler::GemfileError)
/home/romistrub/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/dsl.rb:35:in `eval_gemfile'
/home/romistrub/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/dsl.rb:10:in `evaluate'
/home/romistrub/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/definition.rb:25:in `build'
/home/romistrub/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler.rb:154:in `definition'
/home/romistrub/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler.rb:117:in `setup'
/home/romistrub/.rvm/gems/ruby-2.1.3#global/gems/bundler-1.7.3/lib/bundler/setup.rb:17
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:59:in `gem_original_require'
/usr/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:59:in `require'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:263:in `run_load_path_setup_code'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:366:in `running_bundler'
/usr/lib/ruby/vendor_ruby/phusion_passenger/loader_shared_helpers.rb:261:in `run_load_path_setup_code'
/usr/share/passenger/helper-scripts/rack-preloader.rb:100:in `preload_app'
/usr/share/passenger/helper-scripts/rack-preloader.rb:158
Error ID
506682d5
Rails app gemfile:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.6'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.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'
# 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'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
the command
cat $(which bundle)
gives
#!/usr/bin/env ruby_executable_hooks
#
# This file was generated by RubyGems.
#
# The application 'bundler' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/ and Gem::Version.correct?($1) then
version = $1
ARGV.shift
end
end
gem 'bundler', version
load Gem.bin_path('bundler', 'bundle', version)
command
rake about
gives
About your application's environment
Ruby version 2.1.3-p242 (x86_64-linux)
RubyGems version 2.2.2
Rack version 1.5
Rails version 4.1.6
JavaScript Runtime Node.js (V8)
Active Record version 4.1.6
Action Pack version 4.1.6
Action View version 4.1.6
Action Mailer version 4.1.6
Active Support version 4.1.6
Middleware Rack::Sendfile, ActionDispatch::Static, Rack::Lock, # <ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x00000004ec86d8>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag
Application root /var/www/board/demo
Environment development
Database adapter sqlite3
Database schema version 0
I have no idea where to even start with this one.
Any help is greatly appreciated. Thanks in advance.
Turns out it was an issue with Passenger on RVM, wherein Passenger was using the wrong ruby binary.
After making sure I was using the right Ruby in RVM via
ruby use 2.1
then checking that I was using the proper PassengerRuby directive in Apache using
passenger-config --ruby-command
then changing the Apache configuration to the result of the above command:
PassengerRuby /home/<user>/.rvm/gems/ruby-2.1.3/wrappers/ruby
everything worked.
Well, almost. I encountered another error: a missing SECRET_KEY_BASE ENV. To fix that, I added to the /etc/apache2/envvars the following line:
export SECRET_KEY_BASE=<thisisthesupersecretsecretkeypleasedontcopy>
And restarted apache. Now my only problem is the following error, which I hope has a basic fix:
The page you were looking for doesn't exist.

Trouble Deploying to Heroku

Alright, I'm new to this and really need some guidance here.
I cannot deploy to Heroku to save my life and have been at it for 8 hours and read every stackoverflow and google post I can find.
Ruby Version ----> ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
Rails Version ----> Rails 4.0.0
PostgreSQL ----> psql (PostgreSQL) 9.3.4
Here's what I have going on:
$ git push heroku master
Initializing repository, done.
Counting objects: 62, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (51/51), done.
Writing objects: 100% (62/62), 14.40 KiB | 0 bytes/s, done.
Total 62 (delta 3), reused 0 (delta 0)
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.6.3
Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
Fetching gem metadata from https://rubygems.org/..........
Fetching additional metadata from https://rubygems.org/..
Installing...etc etc etc
Now I get this...
Your bundle is complete!
Gems in the groups development and test were not installed.
It was installed into ./vendor/bundle
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Bundle completed (11.95s)
Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
Gem::LoadError: Specified 'sqlite3' for database adapter, but the gem is not loaded. Add `gem 'sqlite3'` to your Gemfile.
This is what my Gemfile looks like:
source 'https://rubygems.org'
gem 'rails', '4.0.0'
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
gem 'rails_12factor', group: :production
group :assets do
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
end
And here is my database.yml
development:
adapter: postgresql
database: rails_development
pool: 5
timeout: 5000
test:
adapter: postgresql
database: rails_test
pool: 5
timeout: 5000
production:
adapter: postgresql
database: rails_production
pool: 5
timeout: 5000
Type this in your command line: 'gem list'... Let me know if you see 'sqlite3' in the returned list of gems.
Also, put rails_12factor inside your production bloc like so:
group :production do
gem 'pg'
gem 'rails_12factor'
end
Also, add this gem to your development group, and make sure you run bundle install after:
gem 'factory_girl_rails', '~> 4.0'
To minimise differences between development and production (Heroku) I used the Postgresql database in all my environments.

Error When Changing to MySQL2 on Heroku

For my Heroku app (Rails 3.1.4 and Ruby 1.9.2), I'm trying to change to a database that is using MySQL2, but I'm receiving an error from Heroku (which is crashing my app):
3.1.4/lib/active_record/connection_adapters/abstract/connection_specification.rb:71:in `rescue in establish_connection': Please install the mysql12 adapter: `gem install activerecord-mysql12-adapter` (no such file to load -- active_record/connection_adapters/mysql12_adapter) (RuntimeError) EXCEPT
In my gemfile, I have:
group :production do
gem "mysql2", "~> 0.3.11"
end
group :development, :test do
gem 'mysql', '2.8.1'
end
In my database.yml, I have:
development:
adapter: mysql
production:
adapter: mysql2
Here's what I've tried unsuccessfully(all attempts installed correctly locally and in Heroku):
Per this answer, I tried (in my gemfile), mysql2 version "< 0.3"
Per another answer for that question, I tried '< 0.3.7' which didn't work
I tried gem "mysql2", "~> 0.3.11" per this answer, but it didn't work
Per the gem's site, I tried (in my gemfile), mysql2 version "~> 0.2.7" and it installed mysql2 0.2.18 (successfully locally and in Heroku)
I'm sure you've figured this out or moved on long ago, but I was running into the same issue and thought I'd share what worked for me for anyone else who comes along.
In addition to what you mention above, if you're using Heroku you also have to specify mysql2:// in the DATABASE_URL instead of mysql://. See the ClearDB writeup here:
https://devcenter.heroku.com/articles/cleardb
And update their instructions to use mysql2:// instead of mysql:// like so:
heroku config:add DATABASE_URL='mysql2://adffdadf2341:adf4234#us-cdbr-east.cleardb.com/heroku_db?reconnect=true'
Hope that helps.
Try installing the ruby-mysql gem.

Installing PostgreSQL with Ruby on Rails on Mac OS X

I have everything installed. But when I run "rake db:create", I get the following:
Ken-Vogts-MacBook:sixmonths ken$ rake db:create
(in /Users/ken/sixmonths)
rake aborted!
no such file to load -- pg
Here is my database.yml:
development:
adapter: postgresql
encoding: unicode
database: sixmonths_development
pool: 5
username: postgres
password: xxxxxxxx
test:
adapter: postgresql
encoding: unicode
database: sixmonths_test
pool: 5
username: sixmonths
password: xxxxxxxx
production:
adapter: postgresql
encoding: unicode
database: sixmonths_production
pool: 5
username: sixmonths
password: xxxxxxxx
I can see pg is installed when I run: gem list
I tried replacing "postgresql" with "pg" per another post on stackoverflow, but it resulted in this:
Ken-Vogts-MacBook:sixmonths ken$ rake db:create
(in /Users/ken/sixmonths)
Seems cool, right?
Nope. Next, I try "rake db:schema:dump" and I get this:
Ken-Vogts-MacBook:sixmonths ken$ rake db:schema:dump
(in /Users/ken/sixmonths)
rake aborted!
Please install the pg adapter: `gem install activerecord-pg-adapter` (no such file to load -- active_record/connection_adapters/pg_adapter)
Of course there is no "activerecord-pg-adapter". What do I have to do to make this work?
Gemfile Contents:
source 'rubygems.org'
gem 'rails', '3.0.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'unicorn'
# gem 'capistrano'
# gem 'ruby-debug'
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
# gem 'webrat'
# end
Rails 3 will only let you access the gems you specify in your Gemfile, so even if you have it installed in your system-wide gems by doing a gem install pg, it won't be able to find it.
Add gem 'pg' to your Gemfile, run bundle install, and you should be good to go.
I tried many things that I saw as solutions elsewhere, but the only thing that worked for me was replacing
gem 'sqlite3'
with
gem 'pg'
in Gemfile. My database.yml looks the same as yours.
Now both >rake db:create and >rake db:migrate work.
This is on OSX Snow Lepoard, Rails 3.0.7, Postgres 9.0.
And the output from:
gem list --local
is
pg (0.11.0)
polyglot (0.3.1)
postgres-pr (0.6.3)
rack (1.2.2, 1.0.1)
rack-mount (0.7.2, 0.7.1, 0.6.14)
rack-test (0.6.0, 0.5.7)
rails (3.0.7, 3.0.5, 2.3.5, 2.2.2, 1.2.6)