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

#createObject



196
197
198
# File 'app/controllers/concerns/bullet_train/loads_and_authorizes_resource.rb', line 196

def create
  raise "This is a template method that needs to be implemented by controllers including LoadsAndAuthorizesResource."
end

#editObject



192
193
194
# File 'app/controllers/concerns/bullet_train/loads_and_authorizes_resource.rb', line 192

def edit
  raise "This is a template method that needs to be implemented by controllers including LoadsAndAuthorizesResource."
end

#load_teamObject



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

#newObject



188
189
190
# File 'app/controllers/concerns/bullet_train/loads_and_authorizes_resource.rb', line 188

def new
  raise "This is a template method that needs to be implemented by controllers including LoadsAndAuthorizesResource."
end

#reorderObject

These are methods that ‘account_load_and_authorize_resource` assumes will be present on any controllers that call that method. In order to use the new Rails default for `config.raise_on_missing_callback_actions = true` we need to have these methods defined on any controller that includes this module. We define them here so that they will exist at the time that `account_load_and_authorize_resource` is called. We assume that controllers will implement real versions of these methods (if needed) to override these dummy methods. We raise, instead of just defining empty methods, so that if these methods are ever reached it will be more obvious what’s happening that it would be if an empty method were called and it appears that nothing happens.



184
185
186
# File 'app/controllers/concerns/bullet_train/loads_and_authorizes_resource.rb', line 184

def reorder
  raise "This is a template method that needs to be implemented by controllers including LoadsAndAuthorizesResource."
end

#updateObject



200
201
202
# File 'app/controllers/concerns/bullet_train/loads_and_authorizes_resource.rb', line 200

def update
  raise "This is a template method that needs to be implemented by controllers including LoadsAndAuthorizesResource."
end