Class: RepresentationsController

Inherits:
ApplicationController show all
Includes:
PermittedParameters
Defined in:
app/controllers/representations_controller.rb

Overview

Handles CRUD actions for Representation objects

Instance Method Summary collapse

Instance Method Details

#createObject



30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/representations_controller.rb', line 30

def create
  self.representation = current_resource.representations.new(representation_params)

  if representation.save
    logger.info "Created #{representation} for #{current_resource}"
    redirect_to representation, notice: 'The description has been created'
  else
    logger.warn "Unable to create description due to '#{representation.error_sentence}'"
    render :new
  end
end

#destroyObject



52
53
54
55
# File 'app/controllers/representations_controller.rb', line 52

def destroy
  representation.destroy
  redirect_to organization_representations_url(current_organization), notice: 'Description was successfully destroyed.'
end

#editObject



27
28
# File 'app/controllers/representations_controller.rb', line 27

def edit
end

#indexObject



14
15
# File 'app/controllers/representations_controller.rb', line 14

def index
end

#newObject



20
21
22
23
24
25
# File 'app/controllers/representations_controller.rb', line 20

def new
  self.representation = current_resource.representations.new({
    language: Rails.configuration.x.default_representation_language,
    author: current_user
  })
end

#showObject



17
18
# File 'app/controllers/representations_controller.rb', line 17

def show
end

#updateObject



42
43
44
45
46
47
48
49
50
# File 'app/controllers/representations_controller.rb', line 42

def update
  if representation.update(representation_params)
    logger.info "Updated #{representation}"
    redirect_to representation_path(representation), notice: 'The description has been updated'
  else
    logger.warn "Unable to update description due to '#{representation.error_sentence}'"
    render :edit
  end
end