blob: 9c9033e322afcd9da80f137fb7e5694d97d39fc2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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.order([:position])
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 sort
#call_route = RouteElement.find(params[:route_element].first).call_route
params[:route_element].each do |route_element_id|
@call_route.route_elements.find(route_element_id).move_to_bottom
end
render nothing: true
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
|