some thing like this:
John send a message to user1, user2, user3 and user4
this does not work
@users.collect{ |u| link_to(u.name, user_path(u)) }.to_sentence
some thing like this:
John send a message to user1, user2, user3 and user4
this does not work
@users.collect{ |u| link_to(u.name, user_path(u)) }.to_sentence
Odd...
@users.collect{ |u| link_to(u.name, user_path(u)) }.to_sentence
and
@users.map{ |u| link_to(u.name, user_path(u)) }.to_sentence
Should work. What error are you getting?
Make sure you are actually printing out the results with <%= ... %>
, I know I sometimes forget the equal sign and spend a lot of time trying to figure things out.
ez,
link_to
in Erector goes right to the output stream. You either need to replace to_sentence
, patch into link_to's behavior, or replace link_to. As link_to in this context is simple, I'd recommend that:
rawtext users.map { |u|
"<a href='#{user_path(u)}'>#{u.name}</a>"
}.to_sentence