Skip to content

Commit

Permalink
[FS-10] Refactor has company to be has current attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
beetlegius-jt committed Jan 23, 2025
1 parent 1cc1522 commit 8694cd6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/base_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Admin
class BaseController < ApplicationController
include HasCompany
include HasCurrentAttributes
include ErrorHandler
include ActionView::RecordIdentifier

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
module HasCompany
module HasCurrentAttributes
extend ActiveSupport::Concern

included do
before_action :set_current_attributes

def set_current_attributes
Current.user = current_user if user_signed_in?
if user_signed_in?
Current.user = current_user
Current.customer = current_user.customer
end

Current.company = Company.find_by(subdomain: request.subdomain)
end
end
Expand Down
1 change: 1 addition & 0 deletions app/lib/current.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class Current < ActiveSupport::CurrentAttributes
attribute :user
attribute :company
attribute :customer
end

0 comments on commit 8694cd6

Please sign in to comment.