How can i do that besides the “group_id: 3” result the query will
return the Group name too. For example:
You can just say
User.first.group.name
or
user = User.first
group_name = user.group.name
Rails will fetch the group from the database when you reference it.
Alternatively you may use the :include option on find to force it to
fetch the user and group in one query if you are running into
performance problems.
Colin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.