I have worked with devise before but i can't understand what i did wrong this time.All the related questions doesn't explain it as well. As soon as i click the SignUp link, i get the error as follows
ActionController::UnknownFormat in Devise::RegistrationsController#new
in line number 207
(options.delete(:responder) || self.class.responder).call(self, resources, options)
else
207: raise ActionController::UnknownFormat
end
end
However, if i change my link from
<%= link_to "Sign up", new_user_registration_path(resource_name) %>
to
<%= link_to "Sign up", new_user_registration_path %>
the signup page loads just fine. Another thing to note is that when i click the signup link, my url looks like http://localhost:3000/users/sign_up.user
and not like http://localhost:3000/users/sign_up
which should be the case.
I referred Rails 4 Devise 3.1.1 ActionController::UnknownFormat in Devise::RegistrationsController#new and found the idea to remove the resource_name and it seems to work. However, i cant understand why. Thanx in Advance
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.