Reputation: 43
In my view, I'm using this to display the user
Made a comment on <%= link_to activity.trackable.micropost.user, activity.trackable.micropost.user %>
When I do this, it works, but the link shows up as something like #<User:0x5424a68>
I tried using activity.trackable.micropost.user.username
, activity.trackable.micropost.user.name
, and other variations but they didn't work.
What do I need to add after .user?
The activity.trackable
is from the PublicActivity gem.
Upvotes: 0
Views: 101
Reputation: 9754
Try
<%= activity.trackable.micropost.user.inspect %>
or
<%= activity.trackable.micropost.user.to_s %>
This should give you a decent idea of what you need to add..
Upvotes: 0
Reputation: 54674
Open rails console
and type:
User.instance_methods.grep(/name/)
It will give you a list of methods on User
that contain the string 'name'
. Chances are, that you will find the method you are looking for in the list (if there is any).
Upvotes: 2