Perfect. It worked <% rolename = Role.where(id: user.roleid).pluck(:role_name).first %>
And got another way from Stackoverflow <% rolename = Role.find(user.roleid).role_name %> Thank you On Sun, Jul 5, 2015 at 8:38 PM, Elizabeth McGurty <[email protected]> wrote: > End it with .first > > On Sunday, July 5, 2015 at 10:54:45 AM UTC-4, Padmahas Bn wrote: >> >> Before I respond, would you please verify the fields in your table User, >>> specfically roleid. >>> >> >> Elizabeth, >> >> I checked the fields in the database. They exist and as I've posted in >> the question, the code <% rolename = Role.where(id: >> user.roleid).pluck(:role_name) %> working but returns an array. >> >> Thank you >> > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/b4d7aea0-5dcd-4d3b-b175-0a1cf7be84f7%40googlegroups.com > <https://groups.google.com/d/msgid/rubyonrails-talk/b4d7aea0-5dcd-4d3b-b175-0a1cf7be84f7%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAC_h78LGGKA3CjkiGzQMNqD-YzKderoMRGaM1zm5vMa9ii7O-Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

