Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

acl9 has_many through implementation

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
like image 261
Ian Avatar asked Dec 22 '25 06:12

Ian


1 Answers

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
like image 197
acconrad Avatar answered Dec 23 '25 23:12

acconrad



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!