summaryrefslogtreecommitdiff
path: root/app/controllers/route_elements_controller.rb
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-22 15:33:06 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-22 15:33:06 +0100
commit39aa7132ceed3d4beab3a9b828e571bbfc67c07e (patch)
tree6c88289c9f99be0af8635636fcdf64102090e5ec /app/controllers/route_elements_controller.rb
parent5ad8203ce4f1bfea997960d0b52c626dea24b944 (diff)
parent6f69c1a85055ec7c2515719d79d2a7a4e60cec50 (diff)
Merge branch 'develop'5.1-beta1
Diffstat (limited to 'app/controllers/route_elements_controller.rb')
-rw-r--r--app/controllers/route_elements_controller.rb67
1 files changed, 67 insertions, 0 deletions
diff --git a/app/controllers/route_elements_controller.rb b/app/controllers/route_elements_controller.rb
new file mode 100644
index 0000000..c4e4c1a
--- /dev/null
+++ b/app/controllers/route_elements_controller.rb
@@ -0,0 +1,67 @@
+class RouteElementsController < ApplicationController
+ load_and_authorize_resource :call_route
+ load_and_authorize_resource :route_element, :through => [:call_route]
+
+ before_filter :spread_breadcrumbs
+
+ def index
+ @route_elements = @call_route.route_elements
+ end
+
+ def show
+ @route_element = @call_route.route_elements.find(params[:id])
+ end
+
+ def new
+ @route_element = @call_route.route_elements.build
+ end
+
+ def create
+ @route_element = @call_route.route_elements.build(params[:route_element])
+ if @route_element.save
+ redirect_to [@call_route, @route_element], :notice => t('route_elements.controller.successfuly_created')
+ else
+ render :new
+ end
+ end
+
+ def edit
+ @route_element = @call_route.route_elements.find(params[:id])
+ end
+
+ def update
+ @route_element = @call_route.route_elements.find(params[:id])
+ if @route_element.update_attributes(params[:route_element])
+ redirect_to [@call_route, @route_element], :notice => t('route_elements.controller.successfuly_updated')
+ else
+ render :edit
+ end
+ end
+
+ def destroy
+ @route_element = @call_route.route_elements.find(params[:id])
+ @route_element.destroy
+ redirect_to call_route_route_elements_path(@call_route), :notice => t('route_elements.controller.successfuly_destroyed')
+ end
+
+ def move_higher
+ @route_element.move_higher
+ redirect_to :back
+ end
+
+ def move_lower
+ @route_element.move_lower
+ redirect_to :back
+ end
+
+ private
+ def spread_breadcrumbs
+ add_breadcrumb t("call_routes.index.page_title"), call_routes_path
+ add_breadcrumb @call_route, call_route_path(@call_route)
+ add_breadcrumb t("route_elements.index.page_title"), call_route_route_elements_path(@call_route)
+ if @route_element && !@route_element.new_record?
+ add_breadcrumb @route_element, call_route_route_element_path(@call_route, @route_element)
+ end
+ end
+
+end