Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am working on a Rails 4 app using Devise 3.1.1 for user authentication. When I click on /users/sign_up.user link Rails throws 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'
....

I was actually on Devise 3.0.0.rc when started the app, I thought upgrading the devise to 3.1.1 might solve the problem, but it didn't. Couldn't find anything useful on SO/google/devise github project. Any idea how to work around it. Thanks!

like image 229
Zeeshan Avatar asked Oct 05 '13 02:10

Zeeshan


2 Answers

I did not want to change default links produced by Devise which appended ".user" at the end of each link. Devise produced following links:

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

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

like image 67
Zeeshan Avatar answered Sep 23 '22 01:09

Zeeshan


@zeeshan's answer works, you can also the functions without the _user infix:

new_registration_path(resource_name)

new_session_path(resource_name)

new_password_path(resource_name)
like image 33
Daniël W. Crompton Avatar answered Sep 26 '22 01:09

Daniël W. Crompton