Skip to content

Dynamic link_to path's | How to implement #1255

Answered by boardfish
itsyoshio asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there @itsyoshio! I've converted this to a discussion. We tend to use issues for bug reports and feature requests, whereas implementation support is better suited to discussions.

If I'm understanding you correctly, @card refers to a Customer in the first instance and a Location in the second. Here's my suggestion as to what you could do here. Set this up in your config/routes.rb:

direct :location do |model|
  customer_location_path(model.customer, model)
end

This allows you to call location_path(@card)...and, more importantly, url_for(@card). You can now use url_for and pass it a customer or a location to get the desired result.

Alternatively, a method within your component that's as f…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by itsyoshio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1253 on January 24, 2022 10:32.