1
0
Fork 0

Remove method ApplicationController#guest_account

This commit is contained in:
Alex Kotov 2018-12-09 02:55:43 +05:00
parent dd0d7fe6fb
commit be4d382dd0
No known key found for this signature in database
GPG key ID: 4E831250F47DE154
2 changed files with 4 additions and 8 deletions

View file

@ -19,17 +19,13 @@ private
def current_account def current_account
@current_account ||= current_user&.account @current_account ||= current_user&.account
end @current_account ||= Account.guests.find_by(id: session[:guest_account_id])
def guest_account
@guest_account ||= current_account
@guest_account ||= Account.guests.find_by(id: session[:guest_account_id])
end end
def pundit_user def pundit_user
@pundit_user ||= ApplicationPolicy::Context.new( @pundit_user ||= ApplicationPolicy::Context.new(
account: current_account, account: current_account&.guest? ? nil : current_account,
guest_account: guest_account, guest_account: current_account,
) )
end end

View file

@ -19,7 +19,7 @@ class MembershipAppsController < ApplicationController
def create def create
@membership_app = MembershipApp.new permitted_attributes MembershipApp @membership_app = MembershipApp.new permitted_attributes MembershipApp
@membership_app.account = guest_account || Account.new @membership_app.account = current_account || Account.new
authorize @membership_app authorize @membership_app