Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

has_and_belongs_to_many cannot use consistently use find or include?

#1312

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.

Reported by David Liu · October 31st, 2008 @ 05:57 PM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. gaffo
    gaffo

    This is typically because a virus scanner is scanning your tmp file at the same time that you are trying to run this. Make sure nothing else has this file open or add an exception to the scanner so it doesn't hit it. I had this same issue with mysql and my corporate anti virus. I had to move the tmp file to another directory and get an exception added to that file.

    October 31st, 2008 @ 07:20 PM

  2. gaffo
  3. Frederick Cheung
    Frederick Cheung
    • State changed from new to invalid

    Nothing to do with rails :-)

    December 12th, 2008 @ 04:40 PM