aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/line_footnotes_controller.rb
diff options
context:
space:
mode:
authorLuc Donnet2017-07-13 15:34:41 +0200
committerLuc Donnet2017-07-13 15:34:41 +0200
commit8d342e0402d0f4b858c77469ca01f428a45503f0 (patch)
tree6ee0f9ac6211b8b6f057b6f05f9de3626509541a /app/controllers/line_footnotes_controller.rb
parentbc33eba0f1129a491a56bc9b616f388477489b0b (diff)
downloadchouette-core-8d342e0402d0f4b858c77469ca01f428a45503f0.tar.bz2
Fix footnotes policy Refs #4094 @2
Diffstat (limited to 'app/controllers/line_footnotes_controller.rb')
-rw-r--r--app/controllers/line_footnotes_controller.rb29
1 files changed, 11 insertions, 18 deletions
diff --git a/app/controllers/line_footnotes_controller.rb b/app/controllers/line_footnotes_controller.rb
index 6a9048392..f24d624d4 100644
--- a/app/controllers/line_footnotes_controller.rb
+++ b/app/controllers/line_footnotes_controller.rb
@@ -1,16 +1,7 @@
-class LineFootnotesController < BreadcrumbController
- defaults :resource_class => Chouette::Line
- include PolicyChecker
- respond_to :json, :only => :show
+class LineFootnotesController < ChouetteController
+ defaults resource_class: Chouette::Line, collection_name: 'lines', instance_name: 'line'
belongs_to :referential
- def show
- show! do
- build_breadcrumb :show
- end
- @footnotes = @line.footnotes
- end
-
def edit
edit! do
build_breadcrumb :edit
@@ -18,25 +9,27 @@ class LineFootnotesController < BreadcrumbController
end
def update
- if @line.update(line_params)
- redirect_to referential_line_footnotes_path(@referential, @line) , notice: t('notice.footnotes.updated')
- else
- render :edit
+ update! do |success, failure|
+ success.html { redirect_to referential_line_footnotes_path(@referential, @line) , notice: t('notice.footnotes.updated') }
+ failure.html { render :edit }
end
end
protected
+
+ alias_method :line, :resource
+
# overrides default
def check_policy
authorize resource, "#{action_name}_footnote?".to_sym
end
- private
def resource
- @referential = Referential.find params[:referential_id]
- @line = @referential.lines.find params[:line_id]
+ @line ||= current_referential.lines.find params[:line_id]
end
+ private
+
def line_params
params.require(:line).permit(
{ footnotes_attributes: [ :code, :label, :_destroy, :id ] } )