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
489 stars 35 forks source link

task db:find_query_indexes fails when a controller has a method "find_***" #19

Closed razenha closed 13 years ago

razenha commented 13 years ago

One of controllers in my projeect had private a method named "find_attr_by_name". I runned the db:db:find_query_indexes query, it looks like it searchs for "find_xxxx" in all classes and when it found a class with this method it calls the "table_name" attribute from the class. Most of the cases it will be in a model class, but in this case it is a controller class, so the task fails.

Here is the backtrace:


undefined method table_name' for ExportacoesPdvController:Class /Users/razenha/Projects/Pro/portaltrademarketingpoptrade/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:180:incheck_line_for_find_indexes' /Users/razenha/Projects/Pro/portaltrademarketingpoptrade/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:134:in scan_finds' /Users/razenha/Projects/Pro/portaltrademarketingpoptrade/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:112:ineach' /Users/razenha/Projects/Pro/portaltrademarketingpoptrade/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:112:in scan_finds' /Users/razenha/Projects/Pro/portaltrademarketingpoptrade/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:108:ineach' /Users/razenha/Projects/Pro/portaltrademarketingpoptrade/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:108:in scan_finds' /Users/razenha/Projects/Pro/portaltrademarketingpoptrade/vendor/plugins/rails_indexes/tasks/../lib/indexer.rb:279:inar_find_indexes' /Users/razenha/Projects/Pro/portaltrademarketingpoptrade/vendor/plugins/rails_indexes/tasks/indexer.rake:6 /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:636:in call' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:636:inexecute' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:631:in each' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:631:inexecute' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:597:in invoke_with_call_chain' /Users/razenha/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/1.8/monitor.rb:242:insynchronize' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:583:ininvoke' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:2051:in invoke_task' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:2029:in each' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:2023:intop_level' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:2001:in run' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/lib/rake.rb:1998:in run' /Users/razenha/.rvm/gems/ruby-1.8.7-p299/gems/rake-0.8.7/bin/rake:31 /Users/razenha/.rvm/gems/ruby-1.8.7-p299/bin/rake:19:inload'

/Users/razenha/.rvm/gems/ruby-1.8.7-p299/bin/rake:19

eladmeidar commented 13 years ago

hi there, sorry for the late response. i am working on a new version of RailsIndexes, this will be fixed... so stay tuned