I am trying to create rake task to import data from my old php application.But I can not connect to mysql database properly, when I run Old::User.all on rails console ,I get this error :
NoMethodError: undefined method `more_results’ for #
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/mysql_adapter.rb:623:in `select’
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/query_cache.rb:56:in `select_all'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/base.rb:467:in `find_by_sql'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/relation.rb:64:in `to_a'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/relation/finder_methods.rb:143:in `all'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/base.rb:439:in `__send__'
from /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/base.rb:439:in `all'
from (irb):1
Model class Old/user.rb
class Old::User < ActiveRecord::Base
establish_connection “old_database”
Because table name is lowercase
def self.table_name()
"user"
end
end
database.yml
old_database:
adapter: mysql
database: old_database
username: root
password:
socket: /Applications/MAMP/tmp/mysql/mysql.sock