Skip to content

My link_to is not working. #609

Answered by joeldrapper
oporpino asked this question in Help
Discussion options

You must be logged in to vote

Hey, we already figured this out in the Naming Things Discord, but in case someone else finds this, I’ll answer here.

The trick is to use the adapters rather than going through the helpers “proxy”, which is much lower-level. helpers.link_to calls the link_to helper directly and that helper returns HTML. This is because it's designed to be used with <%= %> output ERB tags.

In Phlex, you would expect a helper like link_to to output the HTML rather than return it. You don’t expect to have to pass it to unsafe_raw yourself.

To help with this, phlex-rails provides an adapter for every Rails helper. These adapters are provided as modules to include in your components as needed — though it proba…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by joeldrapper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants