Когда я создаю новую учетную запись (используя devise), меня приветствует испорченная веб-страница и следующая ошибка.
Загрузка учетной записи (0,7 мс). Выберите «пользователи». * ИЗ «пользователей» ГДЕ «пользователи». «Тип» IN («Учетная запись») И «пользователи». «Id» = $ 1 ЗАКАЗАТЬ «пользователи». " id "ASC LIMIT $ 2 [[" id ", 6], [" LIMIT ", 1]]
FinePrint :: Contract Load (1.4ms) ВЫБРАТЬ "fine_print_contracts". * FROM "fine_print_contracts" INNER JOIN "fine_print_contracts" "same_names_fine_print_contracts" ON "same_names_fine_print_contracts". "Name" = "fine_print "contracts" "." версия "НЕ НУЛЯЕТСЯ) И" fine_print_contracts "." name "IN ('конфиденциальность', 'условия') GROUP BY" fine_print_contracts "." id "HAVING" fine_print_contracts "." version "= max (" same_names_fine_print_contracts " . "version") ORDER BY "fine_print_contracts". "name" ASC, "fine_print_contracts". "версия" DESC
FinePrint :: Contract Load (1.0ms) ВЫБЕРИТЕ "fine_print_contracts". * FROM "fine_print_contracts" INNER JOIN "fine_print_contracts" "same_names_fine_print_contracts" ON "same_names_fine_print_contracts". "Name" = "fine_printINcontracts" "ON" fine_print_signatures "." Contract_id "=" fine_print_contracts "." Id "WHERE (" fine_print_contracts "." Версия "NOT NULL) И" fine_print_contracts "." Name "IN ('privacy', 'rules') AND" fine_print_signatures. " "." name "ASC," fine_print_contracts "." version "DESC [[" user_id ", 6], [" user_type "," User "]]
method = GET path = / format = html controller = действие DashboardController = состояние индекса = 302 длительность = 10,24 представление = 0,00 дБ = 2,59 расположение = http://localhost:3000/fine_print/contracts/1/signatures/new
Метод = GET путь = / Fine_print / контракты / 1 / подписи / новый формат = HTML-контроллер = FinePrint :: SignaturesController действие = новый статус = 401 длительность = 0,76 просмотра = 0,00 дБ = 0,00
Если я попытаюсь войти в другую учетную запись, я смогу просмотреть свои контракты, однако, когда я принимаю их, это напоминает мне, что я уже согласился, и не позволит мне продолжить. Единственное, что мне помогает, - это очистить кеш.
FinePrint используется для моей Политики конфиденциальности и Условий. Я требую, чтобы пользователи «подписали» их до входа в панель управления:
dashboard_controller.rb
class DashboardController < ApplicationController
before_action :load_resource
before_action :authenticate_user!
fine_print_require :all
end
fine_print.rb
FinePrint.configure do |config|
# Engine Configuration: Must be set in an initializer
# Layout to be used for FinePrint's controllers
# Default: 'application'
config.layout = 'fine_print'
# Array of custom helpers for FinePrint's controllers
# Default: [] (no custom helpers)
config.helpers = []
# Proc called with a controller as self. Returns the current user.
# Default: lambda { current_user }
config.current_user_proc = lambda { current_user }
# Proc called with a user as argument and a controller as self.
# This proc is called when a user tries to access FinePrint's controllers.
# Should raise and exception, render or redirect unless the user is a manager
# or admin. Contract managers can create and edit agreements and terminate
# accepted agreements. The default renders 403 Forbidden for all users.
# Note: Proc must account for nil users, if current_user_proc returns nil.
# Default: lambda { |user| head(:forbidden) }
config.authenticate_manager_proc = lambda { |user| user&.is_admin? ? true : head(:forbidden) }
# Proc called with a user as argument and a controller as self.
# This proc is called before FinePrint determines if contracts need to be
# signed. If it returns true, FinePrint will proceed with its checks and
# potentially call the redirect_to_contracts_proc with the user as argument.
# If it returns false, renders or redirects, FinePrint will stop its checks.
# Note that returning false will allow the user to proceed without signing
# contracts, unless another before_filter renders or redirects (to a login
# page, for example). The default renders 401 Unauthorized for nil users and
# checks all others for contracts to be signed.
# Default: lambda { |user| !user.nil? || head(:unauthorized) }
config.authenticate_user_proc = lambda { |user| !user.nil? || \
head(:unauthorized) }
# Controller Configuration
# Can be set in this initializer or passed as options to `fine_print_require`
# Proc called with a user and an array of contracts as arguments and a
# controller as self. This proc is called when a user tries to access a
# resource protected by FinePrint, but has not signed all the required
# contracts. Should redirect the user, render or raise an exception.
# The `contracts` argument contains the contracts that need to be signed.
# The default redirects users to FinePrint's contract signing views.
# The `fine_print_return` method can be used to return from this redirect.
# Default: lambda { |user, contracts|
# redirect_to(fine_print.new_contract_signature_path(
# contract_id: contracts.first.id
# ))
# }
config.redirect_to_contracts_proc = lambda { |user, contracts|
redirect_to(
fine_print.new_contract_signature_path(contract_id: contracts.first.id)
)
}
# Proc called whenever a contract is published, useful if the application
# needs to hook into this event and take some action
config.contract_published_proc = lambda { |contract| }
end
Вот мои два контракта на моем местном:
#<FinePrint::Contract id: 1, name: "privacy", version: 1, title: "Privacy Policy", content: "privacy", created_at: "2018-12-29 22:12:40", updated_at: "2018-12-29 22:12:45">
#<FinePrint::Contract id: 2, name: "terms", version: 1, title: "Terms & Conditions", content: "terns", created_at: "2018-12-29 22:12:55", updated_at: "2018-12-29 22:12:59">
Кто-нибудь еще получает эту проблему или есть обходной путь?