Skip to content

Instantly share code, notes, and snippets.

@lujanfernaud
lujanfernaud / rails_dynamic_path_inside_partial.md
Last active April 5, 2022 11:54
Rails: Dynamic Path Inside Partial

Rails: Dynamic Path Inside Partial

We have a _user partial that we want to render from two different resources, passing a collection. The only thing that needs to change in the partial is the path inside the link_to helper.

We can use self.send("path", object) inside link_to to achieve this.

groups/_user.html.erb