hi, i'm having some problems with habtm association, when i try to
list Empresas form a Category, i get the association ID instead of the
Empresa ID, i'm using sqlite3

>> paulo-geyers-macbook:100empresas paulo$ ./script/console
Loading development environment (Rails 2.3.4)
>> Category.find(:first).empresas.each {|e| puts e.id}
608
609
=> [#<Empresa id: 608, name: "Fast Shop", description: nil,
created_at: "2009-09-09 17:55:49", updated_at: "2009-09-09 17:55:49">,
#<Empresa id: 609, name: "Livraria Cultura", description: nil,
created_at: "2009-09-09 17:55:49", updated_at: "2009-09-09 17:55:49">]
>> Empresa.find(:all).each {|e| puts e.id}
54276017
1387109338
=> [#<Empresa id: 54276017, name: "Livraria Cultura", description:
nil, created_at: "2009-09-09 17:55:49", updated_at: "2009-09-09
17:55:49">, #<Empresa id: 1387109338, name: "Fast Shop", description:
nil, created_at: "2009-09-09 17:55:49", updated_at: "2009-09-09
17:55:49">]
>>

here follows the model codes
empresa.rb
class Empresa < ActiveRecord::Base
  has_and_belongs_to_many :categories, :foreign_key =>
'empresa_id', :association_foreign_key => 'category_id'
  validates_presence_of :name
  acts_as_voteable
end

category.rb
class Category < ActiveRecord::Base
  has_and_belongs_to_many :empresas, :foreign_key =>
'category_id', :association_foreign_key => 'empresa_id'
  validates_presence_of :name
end

i've tried to set the keys manually, but didn't work too

thanks,
Paulo
--~--~---------~--~----~------------~-------~--~----~
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