简体   繁体   中英

ActionController::UnknownFormat in Devise::SessionsController#new in rails 4

I am trying for long time and did google about the issue I am unable to get rid of it. Can any one explains why this is happening and how to resolve it.

  def new
    self.resource = resource_class.new(sign_in_params)
    clean_up_passwords(resource)
    respond_with(resource, serialize_options(resource))
  end

The error is in the line following line respond_with(resource, serialize_options(resource))

When I register devise will send a confirmation link. When I click the link getting the above error and here is my url

http://localhost/users/sign_in.47

update 1

Here is my show action of confirmations_controller.rb

  def show
    self.resource = resource_class.confirm_by_token(params[:confirmation_token])
    yield resource if block_given?

    if resource.errors.empty?
      set_flash_message(:notice, :confirmed) if is_flashing_format?
      respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) }
    else
      respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new }
    end
  end

def after_sign_up_or_sign_in_path_for resource
      User.where(id: resource.id).update_all(online: true)
      dashboard_path
    end

I need to update user as online once they logged in so i used resource.id that makes me trouble it seems

在您的ApplicationController中,尝试添加此行(如果它尚未存在):

respond_to :html, :json

The main problem is with .47 at the end of url. Which might be your user id. But need to find where it come from. Might be there is some problem with your confirmation link.

As per your updated question please change following line in after_sign_up_or_sign_in_path_for method.

change this line User.where(id: resource.id).update_all(online: true) to resource.update_attribute(:online, true)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM