MongoDB connection error when I try to install any gem - ruby-on-rails

I am trying to run Rails 3.2.3 using gem 1.8.23, Ruby 1.9.2p318 (2012-02-14 revision 34678) [x86_64-darwin10.8.0], MongoDB 1.6.2 with MongoMapper 0.11.0 and heroku.
I am able to start the rails server and use mongoDB both on development and on heroku. But whenever I try to install anything new (bootstrap for instance) or run 'rails s' command, I get the following error (pasted below). I assume it has something to do with mongodb and or mongo mapper. I have also enclosed the config files. I've been stuck with this since couple of days and any hints or ideas are highly appreciated. Unfortunately, this is my first RoR app and hence I may sound really stupid.
Error:
new-host:talker Name$ rails g bootstrap:install
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from at /Users/Name/Projects/talker/config/environment.rb:12)
/Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/networking.rb:330:in `rescue in receive_message_on_socket': Operation failed with the following exception: connection closed (Mongo::ConnectionFailure)
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/networking.rb:322:in `receive_message_on_socket'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/networking.rb:188:in `receive_header'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/networking.rb:175:in `receive'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/networking.rb:139:in `receive_message'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/cursor.rb:469:in `block in send_initial_query'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/util/logging.rb:36:in `instrument'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/cursor.rb:467:in `send_initial_query'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/cursor.rb:458:in `refresh'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/cursor.rb:128:in `next'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/db.rb:511:in `command'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/connection.rb:628:in `check_is_master'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/connection.rb:402:in `connect'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/connection.rb:589:in `setup'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo-1.6.2/lib/mongo/connection.rb:114:in `initialize'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo_mapper-0.11.1/lib/mongo_mapper/connection.rb:75:in `new'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/mongo_mapper-0.11.1/lib/mongo_mapper/connection.rb:75:in `connect'
from /Users/Name/Projects/talker/config/initializers/mogo.rb:28:in `'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `block in load'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/engine.rb:588:in `block (2 levels) in '
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/engine.rb:587:in `each'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/engine.rb:587:in `block in '
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/Name/Projects/talker/config/environment.rb:12:in `'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application.rb:103:in `require'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/application.rb:103:in `require_environment!'
from /Users/Name/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:25:in `'
from script/rails:6:in `require'
from script/rails:6:in `'
new-host:talker Name$
environment.rb
require File.expand_path('../application', FILE)
Talker::Application.initialize!
mongo.rb
MongoMapper.config = {
Rails.env => { 'uri' => ENV['MONGOHQ_URL'] || 'mongodb://localhost:28017' } }
MongoMapper.connect(Rails.env)
if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
MongoMapper.connection.connect if forked
end
end

Your config file says to connect to localhost:28017, but that's the web console. You probably want localhost:27017.

Related

How to run existing ruby on rails project in linux

I have an existing ruby on rails project on my desktop (Moovit). now i want to run this existing project on my linux. but i can't seem to run it. i dont know if im doing it right. i transferred it to my root folder then i run this code rails new Moovit -s i dont know if this is correct? It's not working and when i checked on my browser. it says hello world . the Moovit project is a website. I've created a backup in case of trouble. I also go to Moovit folder then rails s but it's not working. I also run bundle install but still not working. How should I do it?
info:
Rails 3.2.1
ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux]
bundle show activesupport
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6
when i run
bundle install
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
cd Moovit
rails -s
/usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:239:in `block in require': iconv will be deprecated in the future, use String#encode instead.
=> Booting WEBrick
=> Rails 3.0.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/root/Moovit/config/initializers/wrap_parameters.rb:8:in `block in <top (required)>': undefined method `wrap_parameters' for ActionController::Base:Class (NoMethodError)
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
from /root/Moovit/config/initializers/wrap_parameters.rb:7:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:235:in `load'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:235:in `block in load'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:225:in `load_dependency'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:235:in `load'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/engine.rb:201:in `block (2 levels) in <class:Engine>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/engine.rb:200:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/engine.rb:200:in `block in <class:Engine>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/initializable.rb:25:in `instance_exec'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/initializable.rb:25:in `run'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/initializable.rb:50:in `block in run_initializers'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/initializable.rb:49:in `each'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/initializable.rb:49:in `run_initializers'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/application.rb:134:in `initialize!'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/application.rb:77:in `method_missing'
from /root/Moovit/config/environment.rb:5:in `<top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:239:in `require'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:239:in `block in require'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:225:in `load_dependency'
from /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-3.0.6/lib/active_support/dependencies.rb:239:in `require'
from /root/Moovit/config.ru:3:in `block in <main>'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.2/lib/rack/builder.rb:46:in `instance_eval'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.2/lib/rack/builder.rb:46:in `initialize'
from /root/Moovit/config.ru:1:in `new'
from /root/Moovit/config.ru:1:in `<main>'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.2/lib/rack/builder.rb:35:in `eval'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.2/lib/rack/builder.rb:35:in `parse_file'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.2/lib/rack/server.rb:162:in `app'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.2/lib/rack/server.rb:248:in `wrapped_app'
from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.2/lib/rack/server.rb:213:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/commands/server.rb:65:in `start'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/commands.rb:30:in `block in <top (required)>'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/commands.rb:27:in `tap'
from /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.6/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
also how should i run it on my specific ip address? it seems that on my /var/www/html/ there's an index.html which says hello world. and my ruby on rails project is on root folder. I'm really lost. I thought when just running those commands will make it available to my server?
Go to /config/initializers/wrap_parameters.rb, comment out the previous codes and try this code
ActiveSupport.on_load(:action_controller) do
include ActionController::ParamsWrapper
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
end
Follow Bellow Instruction:
cd project_name
bundle install
rails s
Also which version of rails do you use for project.
Please add config/initializers/wrap_parameters.rb and the restart your server.
ActiveSupport.on_load(:action_controller) do
if self == ActionController::Base
wrap_parameters :format => [:json]
end
end

Devise Invitable LoadError

Problem:
m#m-Lenovo-IdeaPad-Y470:~/Dropbox/software/Rails/CIRCAR_CP_NEW$ rails s
Initialize SymmetricEncryption module.
=> Booting Thin
=> Rails 3.2.6 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/m/Dropbox/software/Rails/CIRCAR_CP_NEW/config/initializers/registrations.rb:1:in `<top (required)>': cannot load such file -- devise_invitable/controllers/registrations (LoadError)
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:245:in `load'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:245:in `block in load'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:245:in `load'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/engine.rb:587:in `each'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/engine.rb:587:in `block in <class:Engine>'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `instance_exec'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/initializable.rb:30:in `run'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `each'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/initializable.rb:54:in `run_initializers'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/application.rb:136:in `initialize!'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/m/Dropbox/software/Rails/CIRCAR_CP_NEW/config/environment.rb:7:in `<top (required)>'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `block in require'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:236:in `load_dependency'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/activesupport-3.2.6/lib/active_support/dependencies.rb:251:in `require'
from /home/m/Dropbox/software/Rails/CIRCAR_CP_NEW/config.ru:3:in `block in <main>'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /home/m/Dropbox/software/Rails/CIRCAR_CP_NEW/config.ru:in `new'
from /home/m/Dropbox/software/Rails/CIRCAR_CP_NEW/config.ru:in `<main>'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/commands/server.rb:46:in `app'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/commands/server.rb:70:in `start'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/commands.rb:55:in `block in <top (required)>'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/commands.rb:50:in `tap'
from /home/m/.rvm/gems/ruby-1.9.3-p194#proof/gems/railties-3.2.6/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
If I run any rake commands, the same thing happens. All my other rails applications work just fine. It's just this one (the one I didn't write) that won't start.
I see that the problem is here: CIRCAR_CP_NEW/config/initializers/registrations.rb:1
CIRCAR_CP_NEW/config/initializers/registrations.rb
module DeviseInvitable::Controllers::Registrations
def self.included(controller)
controller.send :around_filter, :keep_invitation_info, :only => :create
end
...
yield
reset_invitation_info
end if resource_invitable
puts "Keep Invitation Info End"
puts "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
end
I just have no idea what to do about it. My understanding is that Rails is looking for something in this directory
devise_invitable/controllers/registrations
but is not finding it because that directory does not exist. Apparently the code works for the developers in India but they don't feel inclined to help me figure out why it's not running on my machine.
I'm running Ubuntu 12.04
Gemfile:
gem 'devise'
gem 'devise_invitable'
Bundle Install
m#m-Lenovo-IdeaPad-Y470:~/Dropbox/software/Rails/CIRCAR_CP_NEW$ bundle install
Using rake (10.0.4)
...
Using devise (2.2.4)
Using devise_invitable (1.1.8)
...
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
Are you certain that you have the devise gems are:
e.g.
bundle install
EDIT: If we know that the gems have been downloaded, there may be a problem with the Gem's configured load paths.
Within irb or pry run Gem.path
Check each of the returned paths for the devise libraries. If the devise directory structure is not found, we have found your problem.
It was a gem compatibility issue.
After version 1.1.4, the structure of devise_invitable changed.
devise_invitable/controllers/registrations
no longer exists. Therefore
module DeviseInvitable::Controllers::Registrations
needed to change to
module DeviseInvitable::RegistrationsControllers
to reflect the structure of the updated gem.
The other solution would be to add the version number to the gemfile and make sure I am using a compatible version so that things are being referenced as expected.
The server and rake commands now run, but there are a number of other issues I have to figure out now :P

undefined method when trying to build db with activerecord-postgis-adapter

I am trying to deploy a rails application using activerecord-postgis-adapter to heroku, however I keep getting this error.
ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.3.0]
Rails 3.2.13
$ heroku run rake db:schema:load
Running `rake db:schema:load` attached to terminal... up, run.9233
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /app/Rakefile:7)
-- create_table("active_admin_comments", {:force=>true})
...
-- create_table("locations", {:force=>true})
rake aborted!
undefined method `spatial' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::TableDefinition:0x007f6051920618>
/app/vendor/bundle/ruby/2.0.0/gems/rgeo-activerecord-0.5.0/lib/rgeo/active_record/common_adapter_elements.rb:107:in `method_missing'
/app/db/schema.rb:85:in `block (2 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/schema_statements.rb:160:in `create_table'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:466:in `block in method_missing'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:438:in `block in say_with_time'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:438:in `say_with_time'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/migration.rb:458:in `method_missing'
/app/db/schema.rb:80:in `block in <top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/schema.rb:50:in `instance_eval'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/schema.rb:50:in `define'
/app/db/schema.rb:14:in `<top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `block in load'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
/app/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
/app/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.13/lib/active_record/railties/databases.rake:402:in `block (3 levels) in <top (required)>'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
/app/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'
Tasks: TOP => db:schema:load
(See full trace by running task with --trace)
As a temporary fix I simply changed DATABASE_URL by replacing postgres:// to postgis:// as follows:
heroku config:set DATABASE_URL='postgis://user:password#host.compute-1.amazonaws.com:port/dbname'
This is where I found that work around:
https://groups.google.com/forum/#!msg/rgeo-users/SDRhEeMZLWc/nue2sFRV6qwJ
I hear it creates other problems in terms of backing up, etc, according to:
https://github.com/dazuma/activerecord-postgis-adapter/issues/14
This happened to me when I switched to using unicorn as my web server. I found that I had to add a special bit of code to config/unicorn.rb to make it work:
# in config/unicorn.rb
after_fork do |server, worker|
if defined?(ActiveRecord::Base)
config = Rails.application.config.database_configuration[Rails.env]
config['adapter'] = 'postgis'
ActiveRecord::Base.establish_connection(config)
end
end
Found the answer here: https://devcenter.heroku.com/articles/postgis
To fix this issue all I had to do was change my adapter in config/database.yml to 'postgis' from 'postgresql'.
This was what I was supposed to do per my tutorial but I forgot to do it. After than all was well.
So, Heroku Rails will use some database.yml params but not all. For Rails 4.1+ https://devcenter.heroku.com/articles/rails-database-connection-behavior#configuring-connections-in-rails-4-1 states that adapter is ignored.
https://devcenter.heroku.com/articles/rails-database-connection-behavior#active-record-4-1-escape-valve states that it will accept url (so that you can host your database somewhere other than Heroku). No need to hardcode it, do a substitution.
production:
url: <%= ENV.fetch('DATABASE_URL', '').sub(/^postgres/, "postgis") %>

Rails, Sidekiq & Unicorn

I am having some problems getting Sidekiq to run on my VPS. Everything works fine locally but once I deploy I get the following error in my unicorn log:
E, [2012-09-18T21:41:19.670672 #1308] ERROR -- : uninitialized constant MailchimpWorker::Sidekiq (NameError)
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in `const_missing'
/home/deployer/production/releases/20120919013128/app/workers/mailchimp_worker.rb:3:in `<class:MailchimpWorker>'
/home/deployer/production/releases/20120919013128/app/workers/mailchimp_worker.rb:1:in `<top (required)>'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:438:in `each'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:438:in `block in eager_load!'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:436:in `each'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/engine.rb:436:in `eager_load!'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/deployer/production/releases/20120919013128/config/environment.rb:5:in `<top (required)>'
config.ru:4:in `require'
config.ru:4:in `block in <main>'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
/home/deployer/production/shared/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
Here is the contents of my worker file:
class MailchimpWorker
include Sidekiq::Worker
LIST_ID = '844161948b'
def perform(email)
Gibbon.listSubscribe id: LIST_ID, email_address: email
end
end
Any ideas as to what I'm doing wrong?
This looks like gem 'sidekiq' is missing from your Gemfile.
If it works on dev but not production, it sounds like bundler isn't loading the gem in the production environment. Which depends on what group the gem is listed in your Gemfile and also how you deploy (how do you have bundler install your gems on production?).
So, can you post your Gemfile, and also the relevant bits in your deployment scripts?
Also double check that the sidekiq procs are being started using bundle exec.
are you running unicorn inside of bundler?
bundle exec unicorn

rails can't find database.yml

I just removed my database.yml because I'm trying to use Mongoid, and now I'm getting the following:
$ rails server
=> Booting WEBrick
=> Rails 3.0.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application/configuration.rb:88:in `read': No such file or directory - /home/chris-kun/code/thirsty/config/database.yml (Errno::ENOENT)
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application/configuration.rb:88:in `database_configuration'
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/railtie.rb:58:in `block (2 levels) in <class:Railtie>'
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.0.9/lib/active_record/railtie.rb:57:in `block in <class:Railtie>'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `instance_exec'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `run'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:50:in `block in run_initializers'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `run_initializers'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:134:in `initialize!'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing'
from /home/chris-kun/code/thirsty/config/environment.rb:5:in `<top (required)>'
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `block in require'
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency'
from /usr/lib/ruby/gems/1.9.1/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:239:in `require'
from /home/chris-kun/code/thirsty/config.ru:3:in `block in <main>'
from /usr/lib/ruby/gems/1.9.1/gems/rack-1.2.3/lib/rack/builder.rb:46:in `instance_eval'
from /usr/lib/ruby/gems/1.9.1/gems/rack-1.2.3/lib/rack/builder.rb:46:in `initialize'
from /home/chris-kun/code/thirsty/config.ru:1:in `new'
from /home/chris-kun/code/thirsty/config.ru:1:in `<main>'
from /usr/lib/ruby/gems/1.9.1/gems/rack-1.2.3/lib/rack/builder.rb:35:in `eval'
from /usr/lib/ruby/gems/1.9.1/gems/rack-1.2.3/lib/rack/builder.rb:35:in `parse_file'
from /usr/lib/ruby/gems/1.9.1/gems/rack-1.2.3/lib/rack/server.rb:162:in `app'
from /usr/lib/ruby/gems/1.9.1/gems/rack-1.2.3/lib/rack/server.rb:253:in `wrapped_app'
1 #!/usr/bin/env ruby
from /usr/lib/ruby/gems/1.9.1/gems/rack-1.2.3/lib/rack/server.rb:204:in `start'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands/server.rb:65:in `start'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:30:in `block in <top (required)>'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.0.9/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Any ideas?
In config/application.rb, remove the line require 'rails/all' and replace with:
require "rails"
%w(
action_controller
action_mailer
active_resource
rails/test_unit
).each do |framework|
begin
require "#{framework}/railtie"
rescue LoadError
end
end
(This is the contents of rails/all.rb in the railties gem, but with the activerecord line removed).
I had a similair issue before, but it turns out I had some scattered active_record references lying around. Full credit to Dylan Markow for this one!
Removing database.yml when using Mongoid in Rails 3.2
Execute grep -r active_record config/ to find all references, then comment them out!
For those of you who want to use db related functions ex) rake db:seed with mongoid, also add the mongoid railtie:
https://github.com/mongodb/mongoid/tree/master/lib/mongoid/railties
require "rails"
# Import gems in Gemfile
Bundler.require(*Rails.groups)
# important that this is imported after gems in Gemfile are imported
%w(
mongoid
action_controller
action_mailer
active_resource
rails/test_unit
).each do |framework|
begin
require "#{framework}/railtie"
rescue LoadError
end
end
An updated answer for Rails 5 and all future versions of Rails:
You should be using the require snippet from the rails/all.rb file that is current with your version of Rails without the active_record railtie. Here is a link to rails/all.rb on the Rails master branch.
As of writing this it includes a number of new railties which you don't want to miss out on:
require "rails"
%w(
action_controller/railtie
action_view/railtie
action_mailer/railtie
active_job/railtie
action_cable/engine
rails/test_unit/railtie
sprockets/railtie
).each do |railtie|
begin
require railtie
rescue LoadError
end
end

Resources