I am using an array to generate the path for rails link_to links and cannot figure out how to add a binding parameter. Here are my link_to tags:
<%= link_to pluralize(post.comments.count, 'comment'), [post.postable, post] %> <%= link_to "Leave a comment", [post.postable, post] %>
Since I use polymorphic association for messages (and they are nested routes), I cannot just use the paths created by the resource helpers in the routes.rb file.
Previously, I could use the anchor option on paths automatically generated, since I did not use a polymorphic relationship with this model. Here's how it looked:
<%= link_to pluralize(post.comments.count, 'comment'), project_post_path(@project, post, {anchor: 'comments'}) %> <%= link_to "Leave a comment", project_post_path(@project, post, {anchor: 'new-comment'}) %>
Any tips on how to return the anchor tag back to link_to tags when using an array to generate a url? Thanks in advance.
krnjn source share