RegistrationsController

RegistrationsController

本文介绍了Rails 4 Devise 3.1.1 ActionController::UnknownFormat in Devise::RegistrationsController#new的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发使用 Devise 3.1.1 进行用户身份验证的 Rails 4 应用程序.当我点击/users/sign_up.user 链接时,Rails 抛出以下异常:

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'
....

我在启动应用程序时实际上是在 Devise 3.0.0.rc 上,我认为将设备升级到 3.1.1 可能会解决问题,但事实并非如此.在 SO/google/devise github 项目上找不到任何有用的东西.任何想法如何解决它.谢谢!

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!

推荐答案

我不想更改由 Devise 生成的默认链接,这些链接在每个链接的末尾附加了.user".设计产生以下链接:

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,即用户,作为 link_to 方法中路径的参数,它告诉它使用.user"作为格式.所以我只是从每个路径中删除了 resource_name.我想知道为什么 Devise 会这样做!

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!

这篇关于Rails 4 Devise 3.1.1 ActionController::UnknownFormat in Devise::RegistrationsController#new的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 07:38