eval' /home/talos/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in
Closed Undistraction closed 9 years ago
Same issue here.
I think this may be related...
Please, create an issue with the following information here https://github.com/plentz/lol_dba/issues:
***************************
Class: Tag
Association type: has_many
Association options: {:through=>:taggings, :source=>:taggable, :source_type=>"Article"}
Exception: uninitialized constant Tagging::Taggable
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/gems/activerecord-4.0.12/lib/active_record/inheritance.rb:129:in `compute_type'
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/gems/activerecord-4.0.12/lib/active_record/reflection.rb:178:in `klass'
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/gems/lol_dba-1.6.4/lib/lol_dba.rb:127:in `block (2 levels) in check_for_indexes'
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/gems/lol_dba-1.6.4/lib/lol_dba.rb:92:in `each_pair'
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/gems/lol_dba-1.6.4/lib/lol_dba.rb:92:in `block in check_for_indexes'
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/gems/lol_dba-1.6.4/lib/lol_dba.rb:88:in `each'
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/gems/lol_dba-1.6.4/lib/lol_dba.rb:88:in `check_for_indexes'
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/gems/lol_dba-1.6.4/lib/lol_dba.rb:190:in `simple_migration'
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/gems/lol_dba-1.6.4/lib/lol_dba/cli.rb:29:in `start'
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/gems/lol_dba-1.6.4/lib/lol_dba/cli.rb:17:in `start'
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/gems/lol_dba-1.6.4/bin/lol_dba:10:in `<top (required)>'
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/bin/lol_dba:23:in `load'
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/bin/lol_dba:23:in `<main>'
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `eval'
/Users/jeremyvenezia/.rvm/gems/ruby-2.1.3/bin/ruby_executable_hooks:15:in `<main>'
Getting same issue on polymophic on rake with similar exception
@Undistraction @jramos @jvenezia @Austio hey guys, could you try v1.6.6 and see if the bug still happens?
and btw, I will be more then happy to fix this asap if someone can help me build a test case for that(just replicate your namespaced problem here https://github.com/plentz/lol_dba/tree/master/spec/fixtures and create a pull request with the failing bug).
Just ran against 1.6.6 and am getting this on alot of my tests now.
Class: Network Association type: has_many Association options: {:through=>:contacts} Exception: undefined method `klass' for nil:NilClass
@Austio what version of rails you're using? can you send a reduced model that reproduces your problem? I will try to fix this asap :)
No problem, wanted to add more data here. The models are pretty complex in mine and have alot of module stuff.
Class: Post
Association type: has_many
Association options: {:class_name=>"::SupportCategory", :through=>:categories_posts, :source=>:categories}
Exception: undefined method klass' for nil:NilClass /home/talos/.rvm/gems/ruby-2.0.0-p481/gems/lol_dba-1.6.6/lib/lol_dba.rb:117:in
block (2 levels) in check_for_indexes'
/home/talos/.rvm/gems/ruby-2.0.0-p481/gems/lol_dba-1.6.6/lib/lol_dba.rb:90:in each_pair' /home/talos/.rvm/gems/ruby-2.0.0-p481/gems/lol_dba-1.6.6/lib/lol_dba.rb:90:in
block in check_for_indexes'
/home/talos/.rvm/gems/ruby-2.0.0-p481/gems/lol_dba-1.6.6/lib/lol_dba.rb:86:in each' /home/talos/.rvm/gems/ruby-2.0.0-p481/gems/lol_dba-1.6.6/lib/lol_dba.rb:86:in
check_for_indexes'
/home/talos/.rvm/gems/ruby-2.0.0-p481/gems/lol_dba-1.6.6/lib/lol_dba.rb:187:in simple_migration' /home/talos/.rvm/gems/ruby-2.0.0-p481/gems/lol_dba-1.6.6/lib/lol_dba/cli.rb:29:in
start'
/home/talos/.rvm/gems/ruby-2.0.0-p481/gems/lol_dba-1.6.6/lib/lol_dba/cli.rb:17:in start' /home/talos/.rvm/gems/ruby-2.0.0-p481/gems/lol_dba-1.6.6/bin/lol_dba:10:in
<top (required)>'
/home/talos/.rvm/gems/ruby-2.0.0-p481/bin/lol_dba:23:in load' /home/talos/.rvm/gems/ruby-2.0.0-p481/bin/lol_dba:23:in
eval' /home/talos/.rvm/gems/ruby-2.0.0-p481/bin/ruby_executable_hooks:15:in
rails is 4.1.4
This was the simplest case i could find.
class Network
has_many :files, through: :contacts
class Network
class Contact #this is nested
has_many :files, foreign_key: :network_contact_id
@Austio thanks a lot. I will try to look at it today. I will add tests to be sure that we don't break it again in the future :)
@Undistraction @jramos @jvenezia @Austio hey guys, test it again using 1.6.7
. I've fixed a few issues related with older rails versions :)
@plentz was able to run this on 1.6.7
Thanks so much for you help and this gem.
Hi @plentz , thanks for working on this. Unfortunately, I still have the exact same error using 1.6.7. I'm on Rails 4.0.13. It may be related with acts-as-taggable-on gem https://github.com/mbleigh/acts-as-taggable-on which uses polymorphic associations.
It's because I needed to create models for acts-as-taggable-on, and wrote associations.
class Tag < ActiveRecord::Base
has_many :taggings
has_many :articles, through: :taggings, source: :taggable, source_type: 'Article'
...
end
class Tagging < ActiveRecord::Base
belongs_to :tag
belongs_to :taggable, polymorphic: true
...
end
I think this should be ignored, I don't know how. The gem already sets up few indexes, and I don't think I need more:
add_index "taggings", ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true, using: :btree
add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree
...
add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree
First up, here is the dump when I run
rake db:find_indexes
:The app is working fine and the relevant setup is: