3

I got the following deprecation warning on the rails console:

DEPRECATION WARNING: Having additional attributes on the join table of a 
has_and_belongs_to_many association is deprecated and will be removed in Rails 3.1. 
Please use a has_many :through association instead.

The issue lies with the roles_users table that I created following an online step-by-step tutorial.

How do I implement a has_many :through association for acl9? It's beyond me, especially since the user and role models each only use helper methods and no actual has_and_belongs_to_many.

This is how they look like:

class User < ActiveRecord::Base
  acts_as_authentic
  acts_as_authorization_subject  :association_name => :roles
end

class Role < ActiveRecord::Base
  acts_as_authorization_role
end
Ian
  • 369
  • 1
  • 2
  • 11
  • I put an issue on the github page. Hopefully it will be fixed soon. https://github.com/be9/acl9/issues/39 – leetheguy Aug 25 '11 at 21:29

2 Answers2

2

The answer was later discussed in the comments to this GitHub issue.

User model:

acts_as_authorization_subject :association_name => :roles, :join_table_name => :roles_users

Role model:

acts_as_authorization_role :join_table_name => :roles_users
acconrad
  • 3,201
  • 1
  • 22
  • 31
0

Also, for the record, Rails decided not to deprecate the :join_table option for habtm after all, so this went away with a subsequent patch release of Rails - ie. you shouldn't need the options mentioned in the issue if you just upgrade your Rails.

smathy
  • 26,283
  • 5
  • 48
  • 68