[英]HABTM Ruby On Rails Question
When i do user.role_ids i get a list of ids like [1,2,3] is it possible to convert these id's into the role.name of that table so it would look like [Developer, Team Leader] Etc? 当我执行user.role_ids时,我得到一个ID列表,例如[1,2,3],是否可以将这些ID转换为该表的role.name,这样看起来就像[Developer,Team Leader] Etc?
Do i need something like 我需要类似的东西吗
<td><%= user.role_ids.find_by_name(roles_name.to_s) %></td>
我没有收到您的问题,但是呢:
<%= user.roles.collect(&:name) %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.