This project is archived and is in readonly mode.

#1312 ✓invalid
David Liu

has_and_belongs_to_many cannot use consistently use find or include?

Reported by David Liu | October 31st, 2008 @ 05:57 PM | in 2.x

I have defined

has_and_belongs_to_many :update_sites, :uniq => true

And when trying to do:

if (! update_sites.include?(site))
  puts "attach RU " + self.build_fullname + " to site " + site.url
  update_sites << site
end

Got:

C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:150:in log': Mysql::Error: Can't create/write to file 'C:\MySQL5\tmp\#sql_190_0.MYI' (Errcode: 13): SHOW FIELDS FROMrelease_unit_builds_update_sites(ActiveRecord::StatementInvalid)

    from C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:281:in `execute'

    from C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:411:in `columns'

    from C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_and_belongs_to_many_association.rb:147:in `finding_with_ambiguous_select?'

    from C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_and_belongs_to_many_association.rb:50:in `find'

    from C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/association_collection.rb:182:in `find_target'

    from C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/association_proxy.rb:133:in `load_target'

    from C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/association_proxy.rb:124:in `method_missing'

    from C:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/association_collection.rb:162:in `method_missing'

    from C:/RubyProjects/osgiruby/app/models/release_unit_build.rb:32:in `add_site'

    from C:/RubyProjects/osgiruby/db/script/load_db.rb:155:in `fetch_all_features'

    from C:/RubyProjects/osgiruby/db/script/load_db.rb:146:in `each'

    from C:/RubyProjects/osgiruby/db/script/load_db.rb:146:in `fetch_all_features'

    from C:/RubyProjects/osgiruby/db/script/load_db.rb:142:in `each'

    from C:/RubyProjects/osgiruby/db/script/load_db.rb:142:in `fetch_all_features'

    from C:/RubyProjects/osgiruby/db/script/load_db.rb:245

The error happens on the include? test. Using find having similar issue.

Not sure if it is a known issue or usage error.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages