Ruby on rails “我如何解决?”;邀请令牌可以';“不要空白”;不可设计
我在rails应用程序中使用强_参数并设计不可侵犯的_。如果我将其保留为“禁止属性”,则运行时错误就是我得到的。因此,我做了以下工作:Ruby on rails “我如何解决?”;邀请令牌可以';“不要空白”;不可设计,ruby-on-rails,ruby-on-rails-3,devise,Ruby On Rails,Ruby On Rails 3,Devise,我在rails应用程序中使用强_参数并设计不可侵犯的_。如果我将其保留为“禁止属性”,则运行时错误就是我得到的。因此,我做了以下工作: 使用rails g控制器用户/邀请创建了一个新控制器 添加了:邀请=>“用户/邀请”以设计 已填充的用户/investments.rb如下所示: class Users::InvitationsController < Devise::InvitationsController def update self.resource = resou
:邀请=>“用户/邀请”
以设计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
class用户::invitationcontrollerafter\u accept\u path\u for(资源)
其他的
用导航(资源){render:edit}响应
结束
结束
私有的
def允许的参数
参数许可(:utf8,:真实性\u令牌,:邀请\u令牌,:\u方法,
{user:[:邀请\令牌,:密码,:密码\确认]},:提交,
:操作,:控制器)
结束
结束
然而,当我这样做时,我得到了错误“邀请令牌不能为空”。我已经使用
put
检查了allowed_params的值,它似乎在那里。但是,我仍然会出错。我发现了问题,并在计算机上进行了解答