Module: Controller::RestActionsConcernWithPundit

Extended by:
ActiveSupport::Concern
Included in:
Resource::BaseController
Defined in:
app/controllers/concerns/controller/rest_actions_concern_with_pundit.rb

Instance Method Summary collapse

Instance Method Details

#createObject



28
29
30
31
32
33
# File 'app/controllers/concerns/controller/rest_actions_concern_with_pundit.rb', line 28

def create
  @resource = resource_class.new(permitted_params)
  authorize_action
  @resource.save
  respond_with @resource, location: after_create_location
end

#destroyObject



54
55
56
57
58
59
# File 'app/controllers/concerns/controller/rest_actions_concern_with_pundit.rb', line 54

def destroy
  @resource = load_resource
  authorize_action
  @resource.destroy
  respond_with @resource, location: after_destroy_location
end

#editObject



41
42
43
44
45
# File 'app/controllers/concerns/controller/rest_actions_concern_with_pundit.rb', line 41

def edit
  @resource = load_resource
  authorize_action
  respond_with @resource
end

#indexObject



11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/concerns/controller/rest_actions_concern_with_pundit.rb', line 11

def index
  if Itsf::Backend.features?(:ransack)
    @q = collection_scope_with_search_scopes(collection_scope).ransack(params[:q])
    @collection = @q.result.page(params[:page]).per(pagination_size)
  else
    @collection = collection_scope.page(params[:page]).per(pagination_size)
  end
  authorize_action
  respond_with @collection
end

#newObject



22
23
24
25
26
# File 'app/controllers/concerns/controller/rest_actions_concern_with_pundit.rb', line 22

def new
  @resource = initialize_resource
  authorize_action
  respond_with @resource
end

#showObject



35
36
37
38
39
# File 'app/controllers/concerns/controller/rest_actions_concern_with_pundit.rb', line 35

def show
  @resource = load_resource
  authorize_action
  respond_with @resource
end

#updateObject



47
48
49
50
51
52
# File 'app/controllers/concerns/controller/rest_actions_concern_with_pundit.rb', line 47

def update
  @resource = load_resource
  authorize_action
  @resource.update_attributes(permitted_params)
  respond_with @resource, location: after_update_location
end