I have Models: class User < ActiveRecord::Base end class Dozent < User has_and_belongs_to_many :subjects, :foreign_key=>''user_id'' , :join_table => "subjects_users" end class Subject < ActiveRecord::Base has_and_belongs_to_many :dozents, :join_table => "subjects_users", :foreign_key=>''subject_id'' end Join Table is ''subjects_users'': subject_id user_id Controller: class ProbaController < ApplicationController layout false def index subj = Subject.find(1) dozs = subj.dozents render :text=>"Hello World #{dozs}" end end ruby 1.8.5 rails 1.2.3 Windows Wenn I call this controller, I get: ActiveRecord::StatementInvalid in ProbaController#index Mysql::Error: #42S22Unknown column ''subjects_users.dozent_id'' in ''on clause'': SELECT * FROM users INNER JOIN subjects_users ON users.id subjects_users.dozent_id WHERE (subjects_users.subject_id = 1 ) AND ( (users.`type` = ''Dozent'' ) ) RAILS_ROOT: C:/work/unitas/config/.. Application Trace | Framework Trace | Full Trace c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract_adapter.rb:128:in `log'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:243:in `execute'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:399:in `select'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:427:in `find_by_sql'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:997:in `find_every'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:418:in `find'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/has_and_belongs_to_many_association.rb:67:in `find'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/association_collection.rb:159:in `find_target'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/association_proxy.rb:131:in `load_target'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/association_proxy.rb:122:in `method_missing'' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/associations/has_and_belongs_to_many_association.rb:91:in `method_missing'' #{RAILS_ROOT}/app/controllers/proba_controller.rb:7:in `index'' -e:3:in `load'' -e:3 Also settings in my models don''t work, and rails tries to join on subjects_users.dozent_id field. Is it a bug? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---