Rails 4 Devise 3.1.1 ActionController :: UnknownFormat in Devise :: RegistrationsController # new

I am working on a Rails 4 application using Devise 3.1.1 to authenticate users. When I click on the / users / sign _up.user link, Rails throws the following exception:

ActionController::UnknownFormat in Devise::RegistrationsController#new ActionController::UnknownFormat Rails.root: /home/rehan/odesk_work/kiefer-waight/ujoin/ujoin-www Application Trace | Framework Trace | Full Trace actionpack (4.0.0) lib/action_controller/metal/mime_responds.rb:372:in `retrieve_collector_from_mimes' actionpack (4.0.0) lib/action_controller/metal/mime_responds.rb:327:in `respond_with' devise (3.1.1) app/controllers/devise/registrations_controller.rb:8:in `new' actionpack (4.0.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action' actionpack (4.0.0) lib/abstract_controller/base.rb:189:in `process_action' actionpack (4.0.0) lib/action_controller/metal/rendering.rb:10:in `process_action' actionpack (4.0.0) lib/abstract_controller/callbacks.rb:18:in `block in process_action' activesupport (4.0.0) lib/active_support/callbacks.rb:413:in `_run__890637270__process_action__callbacks' .... 

Actually, I was on Devise 3.0.0.rc when I started the application, I thought that upgrading the device to 3.1.1 could solve the problem, but it is not. Could not find anything useful in SO / google / devise github project. Any idea how to get around this. Thanks!

+7
ruby ruby-on-rails ruby-on-rails-4 devise
source share
4 answers

I did not want to change the default links created by Devise, which added ".user" at the end of each link. The developer created the following links:

new_user_registration_path(resource_name) new_user_session_path(resource_name) new_user_password_path(resource_name)

resource_name, which is the user, as a path parameter in the link_to method, which tells it to use the ".user" format as the format. So I just deleted the resource name from each path. I wonder why Devise does it!

+13
source share

@zeeshan answers, you can also perform functions without the _user increment:

 new_registration_path(resource_name) new_session_path(resource_name) new_password_path(resource_name) 
+3
source share

I also solved this problem.

The solution is to return all paths to Devise by default , which means giving up _user .

Please note that we are not able to test this code in the console:

 user = User.all.sample app.new_registration_path(user) 

because Devise uses helper to automatically translate the url so we can't test from the outside.

+1
source share

When you say you click on the /users/sign_up.user link, do you literally mean this exact path? Since .user at the end tells it to try and respond using the user format, akin to pdf , xml or json . Remove it and see what happens.

0
source share

All Articles