Arzee

Joined

50 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in How do I write the correct association?

If I wanted to have a "user_type" column in my "users" table that references to another table called "user_type", how do I write the correct association in rails? For example if my user_type is 1 and 1 is admin in my user_type table, and when I write

user = User.first
user.user_type # I want this to return admin

Thank you in advance

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.