Class: Mappable::MappingsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Mappable::MappingsController
- Defined in:
- app/controllers/mappable/mappings_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
18 19 20 |
# File 'app/controllers/mappable/mappings_controller.rb', line 18 def edit @mapping = Mapping.find(params[:id]) end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/mappable/mappings_controller.rb', line 6 def index @mappings = @map.mappings end |
#new ⇒ Object
14 15 16 |
# File 'app/controllers/mappable/mappings_controller.rb', line 14 def new @mapping = Mapping.new(map: @map) end |
#show ⇒ Object
10 11 12 |
# File 'app/controllers/mappable/mappings_controller.rb', line 10 def show @mapping = Mapping.find(params[:id]) end |
#update ⇒ Object
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 |