rails_indexes
rails_indexes copied to clipboard
has_many :through errors in complex case
Discussion start in https://github.com/eladmeidar/rails_indexes/pull/23 by @mexxer
class Message < ActiveRecord::Base
belongs_to :author, :class_name => "User"
has_many :message_copies
has_many :recipients, :through => :message_copies
class MessageCopy < ActiveRecord::Base
belongs_to :message
belongs_to :recipient, :class_name => "User"
belongs_to :folder
delegate :author, :created_at, :subject, :body, :recipients, :to => :message
class User < ActiveRecord::Base
has_many :sent_messages, :class_name => "Message", :foreign_key => "author_id", :dependent => :destroy
has_many :received_messages, :class_name => "MessageCopy", :foreign_key => "recipient_id"
has_many :new_messages, :class_name => "MessageCopy", :foreign_key => "recipient_id", :conditions => "read = 'f'"
rake aborted! uninitialized constant Recipient /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rspec-core-2.0.1/lib/rspec/core/backward_compatibility.rb:20:in const_missing' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rspec-expectations-2.0.1/lib/rspec/expectations/backward_compatibility.rb:6:inco nst_missing' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/inflector/methods.rb:124:in block in const antize' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/inflector/methods.rb:123:ineach' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/inflector/methods.rb:123:in constantize' /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.0.1/lib/active_support/core_ext/string/inflections.rb:43:inconstantize' /home/max/.bundler/ruby/1.9.1/rails_indexes-0d4e405d5964/lib/rails_indexes.rb:153:in block (2 levels) in check_for_indexes ' /home/max/.bundler/ruby/1.9.1/rails_indexes-0d4e405d5964/lib/rails_indexes.rb:117:ineach_pair' /home/max/.bundler/ruby/1.9.1/rails_indexes-0d4e405d5964/lib/rails_indexes.rb:117:in block in check_for_indexes' /home/max/.bundler/ruby/1.9.1/rails_indexes-0d4e405d5964/lib/rails_indexes.rb:107:ineach' /home/max/.bundler/ruby/1.9.1/rails_indexes-0d4e405d5964/lib/rails_indexes.rb:107:in check_for_indexes' /home/max/.bundler/ruby/1.9.1/rails_indexes-0d4e405d5964/lib/rails_indexes.rb:284:insimple_migration' /home/max/.bundler/ruby/1.9.1/rails_indexes-0d4e405d5964/lib/tasks/rails_indexes.rake:10:in block (2 levels) in <top (requ ired)>'
Fix in 1.1.2 version.
@warpc had you fixed this problem?
@plentz It works, but not in all case
gotcha, thanks! great work btw :)
Thanks! If you have problems, write, i try to fix it