Rails 4 Devise 3.1.1 Actioncontroller::Unknownformat in Devise::Registrationscontroller#New

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

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!

ActionController::UnknownFormat in Devise::RegistrationsController#new. .user appended in URL

When you pass a resource into a path method such as new_user_registration_path, Rails will try to route to the action for that resource and interpolate it into the route. Since you don't have a route which has the matcher for the resource defined for it, Rails will just append .<resource.to_param> onto the end of the URL instead. Obviously this isn't what you want, since sign up doesn't need to take a resource.

The reason you're getting this specific exception is that because devise is attempting to respond to multiple response types (html, json, xml etc), it's parsing .user as the type you wish to receive, hence the unknown format error.

ActionController::UnknownFormat in RegistrationsController#create (Devise)

File uploads doesn't work with remote forms. You should use some other way to upload files.

For example;

  • https://github.com/JangoSteve/remotipart
  • https://github.com/tors/jquery-fileupload-rails

My suggestion is using remotipart.

Rails - ActionController::UnknownFormat when saving and not signed in with Devise

I think the problem is in redirect_to(:back) when request is JSON.

Try to replace it with:

#redirect_to(:back)
format.html { redirect_to(:back) }
format.json { render ..............., status: :created }

Issues with Newly Installed Devise Login (ActionController::UnknownFormat in RegistrationsController#create)

It turned out that Devise autogenerated this for both registrations#new and sessions#new:

  <%= simple_form_for(resource, as: resource_name, url: user_registration_path(resource_name)) do |f| %>

The error disappeared when I removed (resource_name) on each form.

UnknownFormat in Devise::SessionsController#new

I think this might be due to the fact that you have set your application controller to respond only to json. If your Devise Controller inherits from ApplicationController (I think this is the default), then it will expect to see a content-type: json header, or your urls must all end in .json



Related Topics



Leave a reply



Submit