Tiago Batista Xavier

Joined

50 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Namespace rails belongs_to

I have the following configuration

module Account
class Permission <ApplicationRecord
end
end

module Account
class GroupPermission < ApplicationRecord
belongs_to: permission
end
end

Table: account_group_users
account_users_id bigint,
account_groups_id bigint,
Table: account_group_permissions
account_permissions_id bigint,
account_groups_id bigint,
When I try to access the Account :: GroupPermission instance and through it access Account :: Permission returns nil.

Only works if I specify class_name:

logo Created with Sketch.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

© 2022 GoRails, LLC. All rights reserved.