In my view file (*.html.erb), I would like to create a link that shows two model datapoints (name and vote count). In the case of Bobby, who has five votes, it would look graphically like:
Bobby(5).
How do I do this with a link_to, given that the string I want to show includes non-ruby parentheses?
Before turning it into a link, the code is,
<%= user.name %>(<%= link.user.reputation_value_for(:votes).to_i %>)
Thanks very much for your help!
Try this:
When building a string with ruby code in it, just type it normally and put the ruby code you need in between this: #{}
When the page loads, the erb is compiled first and in my string above
will be replaced with Bobby and
will be replace with 8 (if that’s his reputation value) giving you
Bobby(8)