Class: Mappable::MappingsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/mappable/mappings_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



22
23
24
25
26
27
28
29
30
# File 'app/controllers/mappable/mappings_controller.rb', line 22

def create
  @mapping = Mapping.new(params[:mapping])

  if @mapping.save
    redirect_to mappings_path(subject: @mapping.parent_map.subject, attr: @mapping.parent_map.attr.pluralize), notice: 'Mapping was successfully created.'
  else
    render action: "new"
  end
end

#destroyObject



42
43
44
45
46
47
# File 'app/controllers/mappable/mappings_controller.rb', line 42

def destroy
  @mapping = Mapping.find(params[:id])
  @mapping.destroy

  redirect_to mappings_path
end

#editObject



18
19
20
# File 'app/controllers/mappable/mappings_controller.rb', line 18

def edit
  @mapping = Mapping.find(params[:id])
end

#indexObject



6
7
8
# File 'app/controllers/mappable/mappings_controller.rb', line 6

def index
  @mappings = @map.mappings
end

#newObject



14
15
16
# File 'app/controllers/mappable/mappings_controller.rb', line 14

def new
  @mapping = Mapping.new(map: @map)
end

#showObject



10
11
12
# File 'app/controllers/mappable/mappings_controller.rb', line 10

def show
  @mapping = Mapping.find(params[:id])
end

#updateObject



32
33
34
35
36
37
38
39
40
# File 'app/controllers/mappable/mappings_controller.rb', line 32

def update
  @mapping = Mapping.find(params[:id])

  if @mapping.update_attributes(params[:mapping])
    redirect_to mappings_path(subject: @mapping.parent_map.subject, attr: @mapping.parent_map.attr.pluralize), notice: 'Mapping was successfully updated.'
  else
    render action: "edit"
  end
end