Skip to content

Instantly share code, notes, and snippets.

@skizzybiz
Created June 2, 2011 21:01
Show Gist options
  • Save skizzybiz/1005322 to your computer and use it in GitHub Desktop.
Save skizzybiz/1005322 to your computer and use it in GitHub Desktop.
Problems with AR.find
class MainDB::App < ActiveRecord::Base
establish_connection :main_db
set_table_name "APPLICATIONS"
end
main_db:
adapter: mysql2
database: "..."
username: rails
password: "..."
host: "..."
$ rails console
Loading development environment (Rails 3.0.7)
ruby-1.9.2-p180 :001 > MainDB::App.find(1002169)
NoMethodError: undefined method `eq' for nil:NilClass
from /Volumes/Users/joelyou/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.7/lib/active_support/whiny_nil.rb:48:in `method_missing'
from /Volumes/Users/joelyou/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/lib/active_record/relation/finder_methods.rb:299:in `find_one'
from /Volumes/Users/joelyou/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/lib/active_record/relation/finder_methods.rb:289:in `find_with_ids'
from /Volumes/Users/joelyou/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/lib/active_record/relation/finder_methods.rb:107:in `find'
from /Volumes/Users/joelyou/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.7/lib/active_record/base.rb:439:in `find'
from (irb):1
from /Volumes/Users/joelyou/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands/console.rb:44:in `start'
from /Volumes/Users/joelyou/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands/console.rb:8:in `start'
from /Volumes/Users/joelyou/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.7/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
@skizzybiz
Copy link
Author

Solution: the table name was "applications" not "APPLICATIONS"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment