riverrun / phauxth_installer

No longer maintained - Installer for the Phauxth authentication library
13 stars 4 forks source link

Update Templates to use new Routes Alias in Phoenix 1.4 #7

Closed BryanJBryce closed 5 years ago

BryanJBryce commented 5 years ago

https://gist.github.com/chrismccord/bb1f8b136f5a9e4abc0bfc07b832257e

Add a Routes alias and update your router calls

A Routes alias has been added to app_web.ex for view and controller blocks in favor over the previously imported AppWeb.Router.Helpers.

The new Routes alias makes it clearer where page_path/page_url and friends exist and removes compile-time dependencies across your web stack. To use the latest conventions, make the following changes to app_web.ex:

- import AppWeb.Router.Helpers
+ alias AppWeb.Router.Helpers, as: Routes

Next, update any controllers, views, and templates calling your imported helpers or static_path|url, to use the new alias, for example:

- <%= link "show", to: user_path(@conn, :show, @user) %>
+ <%= link "show", to: Routes.user_path(@conn, :show, @user) %>
- <script type="text/javascript" src="<%= static_url(@conn, "/js/app.js") %>"></script>
+ <script type="text/javascript" src="<%= Routes.static_url(@conn, "/js/app.js") %>"></script>
BryanJBryce commented 5 years ago

@riverrun I can take this on, but how do you want to handle backwards compatibility with older versions of Phoenix, do you care to?

riverrun commented 5 years ago

I am about to release version 2.0.0, and so maybe we can work on having 2.0 go with Phoenix 1.4.

riverrun commented 5 years ago

Fixed in #11