Module: BulletTrain::LoadsAndAuthorizesResource
- Extended by:
- ActiveSupport::Concern
- Included in:
- LoadsAndAuthorizesResource
- Defined in:
- app/controllers/concerns/bullet_train/loads_and_authorizes_resource.rb
Instance Method Summary collapse
Instance Method Details
#load_team ⇒ Object
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'app/controllers/concerns/bullet_train/loads_and_authorizes_resource.rb', line 160 def load_team @team ||= @child_object&.try(:team) || @parent_object&.try(:team) return unless @team if defined?(Current) && Current.respond_to?(:team=) Current.team = @team end # If the currently loaded team is saved to the database, make that the user's new current team. if @team.try(:persisted?) if can? :show, @team current_user.update_column(:current_team_id, @team.id) end end end |