summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-16 16:32:59 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-01-16 16:32:59 +0100
commit0ee17f52f8ad337c1240b4c55dbd8f6c6c74dc90 (patch)
tree1016d6e8f1d35629d82ef462fed20827d17c4e3d /app/controllers
parent225a812d5f2da7dc205c021a571ff3c6d5307f20 (diff)
Fixed routes and breadcrumbs. #106
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/call_routes_controller.rb19
-rw-r--r--app/controllers/route_elements_controller.rb36
2 files changed, 39 insertions, 16 deletions
diff --git a/app/controllers/call_routes_controller.rb b/app/controllers/call_routes_controller.rb
index 631339b..41abe6d 100644
--- a/app/controllers/call_routes_controller.rb
+++ b/app/controllers/call_routes_controller.rb
@@ -1,14 +1,15 @@
class CallRoutesController < ApplicationController
+ load_and_authorize_resource :call_route
+
+ before_filter :spread_breadcrumbs
+
def index
- @call_routes = CallRoute.all
end
def show
- @call_route = CallRoute.find(params[:id])
end
def new
- @call_route = CallRoute.new
end
def create
@@ -21,11 +22,9 @@ class CallRoutesController < ApplicationController
end
def edit
- @call_route = CallRoute.find(params[:id])
end
def update
- @call_route = CallRoute.find(params[:id])
if @call_route.update_attributes(params[:call_route])
redirect_to @call_route, :notice => t('call_routes.controller.successfuly_updated')
else
@@ -34,8 +33,16 @@ class CallRoutesController < ApplicationController
end
def destroy
- @call_route = CallRoute.find(params[:id])
@call_route.destroy
redirect_to call_routes_url, :notice => t('call_routes.controller.successfuly_destroyed')
end
+
+ private
+ def spread_breadcrumbs
+ add_breadcrumb t("call_routes.index.page_title"), call_routes_path
+ if @call_route && !@call_route.new_record?
+ add_breadcrumb @call_route, call_route_path(@call_route)
+ end
+ end
+
end
diff --git a/app/controllers/route_elements_controller.rb b/app/controllers/route_elements_controller.rb
index 595a20d..699fcc6 100644
--- a/app/controllers/route_elements_controller.rb
+++ b/app/controllers/route_elements_controller.rb
@@ -1,41 +1,57 @@
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 = RouteElement.all
+ @route_elements = @call_route.route_elements
end
def show
- @route_element = RouteElement.find(params[:id])
+ @route_element = @call_route.route_elements.find(params[:id])
end
def new
- @route_element = RouteElement.new
+ @route_element = @call_route.route_elements.build
end
def create
- @route_element = RouteElement.new(params[:route_element])
+ @route_element = @call_route.route_elements.build(params[:route_element])
if @route_element.save
- redirect_to @route_element, :notice => t('route_elements.controller.successfuly_created')
+ redirect_to [@call_route, @route_element], :notice => t('route_elements.controller.successfuly_created')
else
render :new
end
end
def edit
- @route_element = RouteElement.find(params[:id])
+ @route_element = @call_route.route_elements.find(params[:id])
end
def update
- @route_element = RouteElement.find(params[:id])
+ @route_element = @call_route.route_elements.find(params[:id])
if @route_element.update_attributes(params[:route_element])
- redirect_to @route_element, :notice => t('route_elements.controller.successfuly_updated')
+ redirect_to [@call_route, @route_element], :notice => t('route_elements.controller.successfuly_updated')
else
render :edit
end
end
def destroy
- @route_element = RouteElement.find(params[:id])
+ @route_element = @call_route.route_elements.find(params[:id])
@route_element.destroy
- redirect_to route_elements_url, :notice => t('route_elements.controller.successfuly_destroyed')
+ redirect_to call_route_route_elements_path(@call_route), :notice => t('route_elements.controller.successfuly_destroyed')
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