Hi,

I´m able to get the data I want with AchievoPerson.find and
AchievoProject.find, but the has_and_belongs_to_many associations wont
work.
Any suggestions or links to posts that might help me out would be
highly appreciated!


p = AchievoPerson.find(:first)  # => Find a person which is connected
to projects in the project_person table
>> p.projects
NameError: uninitialized constant AchievoPerson::AchievoProjects
  from ../rails/activesupport/lib/active_support/dependencies.rb:
492:in `const_missing'
  from ../rails/activerecord/lib/active_record/base.rb:1909:in
`compute_type'
  from ../rails/activerecord/lib/active_record/reflection.rb:129:in
`send'
  from ../rails/activerecord/lib/active_record/reflection.rb:129:in
`klass'
  from ../rails/activerecord/lib/active_record/reflection.rb:137:in
`quoted_table_name'
  from ../rails/activerecord/lib/active_record/associations/
has_and_belongs_to_many_association.rb:82:in `construct_sql'
  from ../rails/activerecord/lib/active_record/associations/
association_collection.rb:8:in `initialize'
  from ../rails/activerecord/lib/active_record/associations.rb:1128:in
`new'
  from ../rails/activerecord/lib/active_record/associations.rb:1128:in
`projects'


class AchievoProject < ActiveRecord::Base
  establish_connection :achievo
  self.abstract_class = true
  set_primary_key "id"

  def self.table_name() "project" end
  def get_active
    AchievoProject.find(:all, :conditions =>{:status => 'active'} )
  end

  has_and_belongs_to_many :persons, :class_name =>
"AchievoPersons", :join_table => "project_person", :foreign_key =>
"projectid"
end


class AchievoPerson < ActiveRecord::Base
  establish_connection :achievo
  set_primary_key "id"

  def self.table_name() "person" end
  has_and_belongs_to_many :projects, :class_name =>
"AchievoProjects", :join_table => "project_person", :foreign_key =>
"personid"
end

#---
#    mysql> describe project_person;
#    +-----------+---------+------+-----+---------+-------+
#    | Field     | Type    | Null | Key | Default | Extra |
#    +-----------+---------+------+-----+---------+-------+
#    | projectid | int(10) | NO   | PRI | 0       |       |
#    | personid  | int(10) | NO   | PRI | 0       |       |
#    | role      | int(10) | NO   | PRI | 0       |       |
#    +-----------+---------+------+-----+---------+-------+
#---



--
Best Regards,
Martin Stabenfeldt

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to