Ruby on rails 制定不可侵犯的服务条款

Ruby on rails 制定不可侵犯的服务条款,ruby-on-rails,devise,devise-invitable,Ruby On Rails,Devise,Devise Invitable,我正在尝试将服务条款复选框添加到我的Desive invitable视图中。 因此,发出邀请,工程师单击“接受邀请”链接并到达下表: <h2><%= t 'devise.invitations.edit.header' %></h2> <%= simple_form_for resource, as: resource_name, url: invitation_path(resource_name), html: { method: :put } d

我正在尝试将服务条款复选框添加到我的Desive invitable视图中。 因此,发出邀请,工程师单击“接受邀请”链接并到达下表:

<h2><%= t 'devise.invitations.edit.header' %></h2>

<%= simple_form_for resource, as: resource_name, url: invitation_path(resource_name), html: { method: :put } do |f| %>
  <%= devise_error_messages! %>

  <%= f.hidden_field :invitation_token %>

  <%= f.input :first_name %>
  <%= f.input :last_name %>

  <%= f.input :password %>
  <%= f.input :password_confirmation %>

  <%= f.input :terms_of_service, as: :boolean, required: true, label: ("I agree to the #{link_to 'Terms of Service', page_path('terms'), target: :_blank}").html_safe %>

  <%= f.button :submit, t("devise.invitations.edit.submit_button") %>
<% end %>

原来是因为我有一个客户设计控制器,但同时也是工程师手下不可侵犯的东西。我把参数放错了档案


我不得不在Engineers::InvitationController中允许它们。结果证明,因为我有一个客户Desive controller,但同时也是Engineers下的Invitations对象。我把参数放错了档案


我不得不在Engineers::InvitationController中允许它们。

你能发布表单提交时生成的参数散列吗?我看到触发的操作是更新。尝试将
:服务条款
放入
帐户更新
参数,直到运气不佳。如果我删除validates_acceptance_上的allow_nil:false,即使复选框未选中,它也会通过。您可以发布表单提交时生成的参数散列吗?嗯,我看到触发的操作是更新的。尝试将
:服务条款
放入
帐户更新
参数,直到运气不佳。如果我在validates\u acceptance上删除allow\u nil:false,即使未选中复选框,它也会通过
class Engineer < ApplicationRecord
  devise :invitable, :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable

  attr_accessor :terms_of_service
.
.
.
  validates_acceptance_of :terms_of_service, if: :invitation_accepted_at?, acceptance: true, allow_nil: false
class CustomDeviseController < ActionController::Base
  before_action :configure_permitted_parameters, if: :devise_controller?
.
.
.
  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name])
    devise_parameter_sanitizer.permit(:accept_invitation, keys: [:first_name, :last_name, :terms_of_service])
  end
{"utf8"=>"✓", "authenticity_token"=>"aoGCMoYRcmJ2EmpM8L+UmQQcB99FScgA6nFM0kY+53dxDodCZDislej48+lBL4Qcb5ZgAcGHyd1A+3qkIol6KA==", "engineer"=>{"invitation_token"=>"e9oVkxuYMtX9Fzxao7xR", "first_name"=>"sad", "last_name"=>"test", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "terms_of_service"=>"0"}, "commit"=>"Create Account"}
Unpermitted parameter: :terms_of_service