Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Jon Moss
1,150 PointsDevise routes being awkward
Devise is causing new_user_registration_path to link to registrations/new.user for no reason, I'm not sure why this is happening. I've barely customized Devise routes, and I'm not clear why this is happening. I ran rake routes, the output is below
Prefix Verb URI Pattern Controller#Action
new_user_session GET /auth/signin(.:format) devise/sessions#new
user_session POST /auth/signin(.:format) devise/sessions#create
destroy_user_session DELETE /auth/logout(.:format) devise/sessions#destroy
user_password POST /auth/password(.:format) devise/passwords#create
new_user_password GET /auth/password/new(.:format) devise/passwords#new
edit_user_password GET /auth/password/edit(.:format) devise/passwords#edit
PATCH /auth/password(.:format) devise/passwords#update
PUT /auth/password(.:format) devise/passwords#update
cancel_user_registration GET /auth/cancel(.:format) devise/registrations#cancel
user_registration POST /auth(.:format) devise/registrations#create
new_user_registration GET /auth/signup(.:format) devise/registrations#new
edit_user_registration GET /auth/edit(.:format) devise/registrations#edit
PATCH /auth(.:format) devise/registrations#update
PUT /auth(.:format) devise/registrations#update
DELETE /auth(.:format) devise/registrations#destroy
root GET / pages#home
registrations GET /registrations(.:format) registrations#index
POST /registrations(.:format) registrations#create
new_registration GET /registrations/new(.:format) registrations#new
edit_registration GET /registrations/:id/edit(.:format) registrations#edit
registration GET /registrations/:id(.:format) registrations#show
PATCH /registrations/:id(.:format) registrations#update
PUT /registrations/:id(.:format) registrations#update
DELETE /registrations/:id(.:format) registrations#destroy
Jon Moss
1,150 Pointshttps://gist.github.com/maclover7/35a0bfbf486540ef690a. Also, the registrations scaffold is apart of the functionality of my app, and wasn't intended to have any effect on Devise.
1 Answer
Kenan Memis
47,314 PointsHi Jon,
Devise has a shared links template under
app/views/devise/shared/_links.html.erb
if you check that file you will see this line of code:
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end -%>
Your other registrations controller conflicts with this url. You can see this path is existing in your routes.rb file also for registrations controller.
new_registration GET /registrations/new(.:format) registrations#new
Since new action does not take any parameters (unless a nested routing exist),
new_registration_path(resource_name) has a URI Pattern as
/registrations/new.user
You have to fix this conflict.
If you rename the registrations controller with something else, then you will see that new_registration_path(resource_name) is referring to /auth/signup link.
Brandon Barrette
20,485 PointsBrandon Barrette
20,485 PointsPlease also post your routes.rb file too.