diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/line_footnotes_controller.rb | 29 |
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 ] } ) |
