eladmeidar / rails_indexes

A rake task to track down missing database indexes. does not assume that all foreign keys end with the convention of _id.
http://blog.eizesus.com/2009/9/find-where-to-index-your-tables-on-a-rails-app/
MIT License
490 stars 35 forks source link

undefined method `to_a' for "company_id":String (Rails 3 app) #15

Open billsaysthis opened 14 years ago

billsaysthis commented 14 years ago

wgd1 $ rake db:index_migration --trace

DEPRECATION WARNING: Having rake tasks in PLUGIN_PATH/tasks or PLUGIN_PATH/rails/tasks is deprecated. Use to PLUGIN_PATH/lib/tasks instead. (called from load_tasks at /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/plugin.rb:31) DEPRECATION WARNING: Having rake tasks in PLUGIN_PATH/tasks or PLUGIN_PATH/rails/tasks is deprecated. Use to PLUGIN_PATH/lib/tasks instead. (called from load_tasks at /usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/plugin.rb:31)

* Invoke db:index_migration (first_time) * Invoke environment (first_time) * Execute environment * Execute db:index_migration rake aborted! undefined method to_a' for "company_id":String /Users/billlazar/Sites/wested/wgg/wgd1/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:216:inkey_exists?' /Users/billlazar/Sites/wested/wgg/wgd1/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:229:in block (2 levels) in simple_migration' /Users/billlazar/Sites/wested/wgg/wgd1/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:228:ineach' /Users/billlazar/Sites/wested/wgg/wgd1/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:228:in block in simple_migration' /Users/billlazar/Sites/wested/wgg/wgd1/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:227:ineach' /Users/billlazar/Sites/wested/wgg/wgd1/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:227:in simple_migration' /Users/billlazar/Sites/wested/wgg/wgd1/vendor/plugins/rails_indexes/tasks/indexer.rake:10:inblock (2 levels) in <top (required)>' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in call' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:inblock in execute' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in each' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:inexecute' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:597:in block in invoke_with_call_chain' /usr/local/lib/ruby/1.9.1/monitor.rb:190:inmon_synchronize' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:583:ininvoke' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2051:in invoke_task' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:inblock (2 levels) in top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in each' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:inblock in top_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2023:intop_level' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2001:in block in run' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:1998:in run' /usr/local/lib/ruby/gems/1.9.1/gems/rake-0.8.7/bin/rake:31:in<top (required)>' /usr/local/bin/rake:19:in load' /usr/local/bin/rake:19:in

'

bananastalktome commented 14 years ago

I had the same issue. It is because in ruby 1.9, String#to_a no longer exists. I submitted a pull request for my fork at http://github.com/bananastalktome/rails_indexes which has the fix applied.

raid5 commented 13 years ago

Fixed?

plentz commented 12 years ago

I maintaining plentz/lol_dba gem. It should work there :)