Class: ContextsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/contexts_controller.rb

Overview

Handles requests for Context information

See Also:

Instance Method Summary collapse

Instance Method Details

#createObject

POST /contexts



28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/contexts_controller.rb', line 28

def create
  self.context = current_organization.contexts.new(context_params)

  if context.save
    logger.info "Created #{context}"
    redirect_to [current_organization,context], notice: 'Context was successfully created.'
  else
    logger.warn "Unable to create context: '#{context.error_sentence}'"
    render :new
  end
end

#destroyObject

DELETE /contexts/1



51
52
53
54
55
56
57
58
59
60
61
# File 'app/controllers/contexts_controller.rb', line 51

def destroy
  if context.destroy
    flash[:notice] = 'Context was successfully destroyed.'
  else
    msg = "Unable to destroy #{context}: #{context.error_sentence}"
    logger.warn msg
    flash[:error] = msg
  end

  redirect_to organization_contexts_url(current_organization)
end

#editObject

GET /contexts/1/edit



24
25
# File 'app/controllers/contexts_controller.rb', line 24

def edit
end

#indexObject

GET /contexts



11
12
# File 'app/controllers/contexts_controller.rb', line 11

def index
end

#newObject

GET /contexts/new



19
20
21
# File 'app/controllers/contexts_controller.rb', line 19

def new
  self.context = current_organization.contexts.new
end

#showObject

GET /contexts/1



15
16
# File 'app/controllers/contexts_controller.rb', line 15

def show
end

#updateObject

PATCH/PUT /contexts/1



41
42
43
44
45
46
47
48
# File 'app/controllers/contexts_controller.rb', line 41

def update
  if context.update(context_params)
    redirect_to [current_organization,context], notice: 'Context was successfully updated.'
  else
    logger.warn "Unable to update #{context}: #{context.error_sentence}"
    render :edit
  end
end