need help on special HABTM relation

hey all,
I have three tables like this:
forum (id,title)
usergroup(id,title)
forum_perms(usergroup_id,forum_id,read,write,post)

is there a way to deal with that kind of relation with rails such as by using has_and_belongs_to_many kind of stuff?

thanx in advance

Pat

Uhm .... Dont see the HABTM relationship here ?!?

From what you describe (which is not much, i have to guess your

relations), would think this is
what you think of:

class ForumPerms ActiveRecord::Base
belongs_to :forum
belongs_to :usergroup
end

class Forum ActiveRecord::Base
has_many :forum_perms
end

class Usergroup ActiveRecord::Base
has_many :forum_perms

def has_access_on(forum,accparams)
  forumperm = ForumPerm.new(accparams)
  forumperm.forum = forum
  forumperm.user = self
  forumperm.save
end
end

see? no HABTM, just 2 has_many <-> belongs_to
and i added a method to the user class to easily add a new permission
for a forum to a group:
the you can simply do:

usergroup = Usergroup(1) # select some group for this example
forum = Forum(1) # select some forum for this example
@usergroup.has_access_on(forum, {:read => true, :write => false, :post
=> true } )

what is done in the method can be done "by hand" in the controller too,
its just nicer this way ... and maybe there are may be nicer ways,

As always: im more a new rails user, and make many mistakes so dont be
disappointed if i made some errors...

Do you have the following relationships between your tables?

a) Does forum have many usergroups?

b) Does usergroup have many forums?

The forum_perms looks like the join table with additional attributes associated to break the many-to-many relationship between the other two tables. If so then you need to use has_many :through to deal with this scenario.

ok thanx to all. Actually usergroups have many permissions on each forum.
So I guess what I should do is:

Usergroup has_many :forums, :through => :forum_perms
and
Forum has_many :usergroups, :through => :forum_perms

is that right?

thanx in advance

Pat