Ask A Question

Notifications

You’re not receiving notifications from this thread.

Namespace rails belongs_to

Tiago Batista Xavier asked in Rails

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:

Reply

Hi Tiago, is this a typo?
belongs_to: permission
It should be belongs_to :permission

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 83,453+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.