Hi,
Is there some problem with the habtm “_ids” function. See this
example:
class User < ActiveRecord::Base
has_and_belongs_to_many :groups
end
class Group < ActiveRecord::Base
has_and_belongs_to_many :users
end
g=Group.find(1)
print “size=”, g.users.size, “\n”
a=g.user_ids
Here is the output:
Group Load (0.000789) SELECT * FROM groups WHERE (groups.id = 1)
LIMIT 1
Group Columns (0.001408) SHOW FIELDS FROM groups
Join Table Columns (0.000971) SHOW FIELDS FROM groups_users
User Load (0.002074) SELECT * FROM users INNER JOIN groups_users
ON users.id = groups_users.user_id WHERE (groups_users.group_id = 1 )
size=2
/usr/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1792:in
method_missing': undefined method
user_ids’ for #Group:0xb7923e60
(NoMethodError)
As you can see, there are records in the association, but the “_ids”
function is missing?
Any ideas?
Thanks,
David