All threads / Namespace rails belongs_to
Ask A Question


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

module Account
class GroupPermission < ApplicationRecord
belongs_to: permission

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:

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

Join the discussion

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

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

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

    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

    © 2023 GoRails, LLC. All rights reserved.