我尝试了很长时间,并用谷歌搜索了我无法摆脱的问题。任何人都可以解释为什么会发生这种情况以及如何解决它。
def new
self.resource = resource_class.new(sign_in_params)
clean_up_passwords(resource)
respond_with(resource, serialize_options(resource))
end
错误在下一行 respond_with(resource, serialize_options(resource))
当我注册时,devise 会发送一个确认链接。当我单击出现上述错误的链接时,这是我的网址
http://localhost/users/sign_in.47
更新 1
这是我的 confirmations_controller.rb 的展示 Action
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
我需要在用户登录后将用户更新为在线,所以我使用了 resource.id,这似乎让我很麻烦
最佳答案
在您的 ApplicationController 中尝试添加此行(如果它不存在的话):
respond_to :html, :json
关于ruby-on-rails - ActionController::UnknownFormat in Devise::SessionsController#rails 4 中的新功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25487836/