我在rails应用程序中使用了strong_parameters和devise_invitable。如果我离开它,因为它是“禁止属性”运行时错误是我得到的。所以我做了以下事情:
rails g controller users/invitations
:invitations => "users/invitations"
添加到devise_for 填充的用户/ invitations.rb如下:
class Users::InvitationsController < Devise::InvitationsController
def update
self.resource = resource_class.accept_invitation!(allowed_params)
if resource.errors.empty?
set_flash_message :notice, :updated
sign_in(resource_name, resource)
respond_with resource, :location => after_accept_path_for(resource)
else
respond_with_navigational(resource){ render :edit }
end
end
private
def allowed_params
params.permit(:utf8,:authenticity_token,:invitation_token, :_method,
{user: [:invitation_token,:password,:password_confirmation]}, :commit,
:action,:controller)
end
end
然而,当我这样做时,我收到错误“邀请令牌不能为空”。我已经使用puts
检查了allowed_params的值,看起来它就在那里。然而,我仍然得到错误。