You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In an scenario, very recurrent by the way, where there's a database containing the users' table and then, diferent databases from diferent apps relying on the first db for the users info, it is impossible to define independent roles.
Example:
APP1 (with DB 1) has rolify, the roles table, and the join table roles_users, but not users.
APP2 (with DB 2) has the table users, and also roles and roles_users.
When assigning a role on APP1, it is impossible to declare that the join table to be used should be the one in APP1, it defaults to the one on the lhs due to the has_and_belongs_to_many behavior.
has_many :through would allow to specify this on the model.
I know this feature was "work in process", but which is the status?
Although the best solution would be to have the ability to define a model for the join_table of has_and_belongs_to_many... but don't think this will be done ever.
Thanks in advance!
The text was updated successfully, but these errors were encountered:
Rails/HasAndBelongsToMany: Prefer has_many :through to has_and_belongs_to_many
has_and_belongs_to_many :users, join_table: :users_roles
Rails/CreateTableWithTimestamps: Add timestamps when creating a new table.
create_table(:users_roles, id: false) do |t|
I looked here on Github and I can see that this topic is already open for a solid couple of years. To turn it into a has_many through with a model, would it be enough if we simply modify the db migration file by adding id, timestamps and replace the relation with has_many through after the file is generated with rolify? Or do you guys think it'd require more changes in the gem code?
In an scenario, very recurrent by the way, where there's a database containing the users' table and then, diferent databases from diferent apps relying on the first db for the users info, it is impossible to define independent roles.
Example:
APP1 (with DB 1) has rolify, the roles table, and the join table roles_users, but not users.
APP2 (with DB 2) has the table users, and also roles and roles_users.
When assigning a role on APP1, it is impossible to declare that the join table to be used should be the one in APP1, it defaults to the one on the lhs due to the has_and_belongs_to_many behavior.
has_many :through would allow to specify this on the model.
I know this feature was "work in process", but which is the status?
Although the best solution would be to have the ability to define a model for the join_table of has_and_belongs_to_many... but don't think this will be done ever.
Thanks in advance!
The text was updated successfully, but these errors were encountered: