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
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'app/controllers/concerns/bullet_train/loads_and_authorizes_resource.rb', line 206 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 |