Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I write the correct association?

Arzee asked in Databases

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

Reply
Join the discussion
Create an account Log in

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

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

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