link_to语法?想要一起超链接(variable.id +"string")

Jaq*_*aqx 1 string ruby-on-rails concatenation link-to

link_to feed_item.votes_for + "Into it!", into_it_micropost_path(feed_item.id)
Run Code Online (Sandbox Code Playgroud)

我基本上希望超链接成为字符串"Into it!"旁边的变量.

我怎么能实现这个目标?谢谢

Ere*_*bih 6

实际上在我看来你的版本应该可以正常工作.

也许试着用另一种方式:

link_to "#{feed_item.votes_for} Into it!", into_it_micropost_path(feed_item.id)
Run Code Online (Sandbox Code Playgroud)

不要忘记,要显示链接,您必须将其放入 <%= %>