Does Router.Helpers module remain accessible in Phoenix 1.7

Hi everyone,

Working on a prototype using phoenix 1.7-rc and ash_authentication_phoenix, and getting the following error:
function MyAppWeb.Router.Helpers.auth_path/2 is undefined (module MyAppWeb.Router.Helpers is not available)

I saw in the release notes that Helpers were superceded by the verified routes with ~p. Is this the reason of the error, or is MyAppWeb.Router.Helpers supposed to be available with 1.7?

Thank you

2 Likes

Hey there! IIRC in the 1.7 rc the call to the router in MyAppWeb has helpers: false in it, and so you’d just need to change that to true.

10 Likes

You’re saving me again, Zach :slight_smile: Thank you!

1 Like

live_path/3 helper seems to be missing even with helpers: true configuration. :man_shrugging:

1 Like

Is ash authentication code calling live_path/3 ?

Hopefully the changelog is updated soon to reflect this change. Currently is is suggesting helpers are still generated by default. PR is pending acceptance.

2 Likes

skip----

There’s no concern of backwards compatibility for newly generated projects. It’s a concern for existing projects updating to 1.7.

Ah, now it makes sense. So new apps ship with ‘false’ by default and can be set to ‘true’. Old apps don’t have any setting and then the fallback is ‘true’, which can be explicitly set to ‘false’ (or removed)

It’s a concern for existing projects updating to 1.7.

The paragraph does not make this clear imho; as it’s not part of the ‘migration’ but of the new feature list. So I read it as:

We have a new feature. This feature replaces the Helpers module generated in your Phoenix router, but helpers will continue to work and be generated (when you create an Phoenix 1.7 app). You can disable router helpers by passing the helpers: false option to use Phoenix.Router.

This would make it clear to me as it makes the situations explicit.

This feature replaces the Helpers module generated in your Phoenix router. For new applications helpers are not generated by default. You can enable router helpers by passing the helpers: true option to use Phoenix.Router.

For existing applications the helpers will continue to work and be generated. You can disable router helpers by passing the helpers: false option to use Phoenix.Router.

1 Like

We may also be able to remove the need for the router helpers in the future for ash authentication.

Hello, can anyone please explain why Helpers are turned off by default? It has some useful functions. Sorry, I don’t use Elixir/Phoenix daily, I’m trying to pick it up (which I did try a few years back as well).

2 Likes

You’re a lifesaver. Running through the TDD Phoenix book and I tried everything to resolve this error. And thanks @axelbdt for posting this question.

Lifesaver!