From 101f49b9e6b017e748729d6563b0e82594ef37f3 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Thu, 28 Feb 2013 19:56:27 -0500 Subject: [PATCH] added mapping_controller and routes, but only implemented create --- app/controllers/mapping_controller.rb | 52 +++++++++++++++++++++++++++ config/routes.rb | 2 ++ 2 files changed, 54 insertions(+) create mode 100644 app/controllers/mapping_controller.rb diff --git a/app/controllers/mapping_controller.rb b/app/controllers/mapping_controller.rb new file mode 100644 index 00000000..8160c6e3 --- /dev/null +++ b/app/controllers/mapping_controller.rb @@ -0,0 +1,52 @@ +class MappingController < ApplicationController + # GET mappings + def index + end + + # GET mappings/new + def new + @mapping = Mapping.new + @user = current_user + respond_with(@mapping) + end + + # POST mappings + def create + @user = current_user + @mapping = Mapping.new() + @mapping.user = @user + if params[:map] + if params[:map][:id] + @map = Map.find(params[:map][:id]) + @mapping.map = @map + end + end + if params[:topic] + if params[:topic][:id] + @topic = Topic.find(params[:topic][:id]) + @mapping.topic = @topic + end + else if params[:synapse] + if params[:synapse][:id] + @topic = Synapse.find(params[:synapse][:id]) + @mapping.synapse = @synapse + end + end + end + + # GET /mappings/:id + def show + end + + # GET /mappings/:id/edit + def edit + end + + # PUT /mappings/:id + def update + end + + # DELETE /mappings/:id + def destroy + end +end diff --git a/config/routes.rb b/config/routes.rb index 9313f6c1..67fe70d1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -39,6 +39,8 @@ ISSAD::Application.routes.draw do resources :synapses, :only => [:index] resources :maps, :only => [:index] end + + resources :mappings # The priority is based upon order of creation: # first created -> highest priority.