app/controllers/effective/regions_controller.rb in effective_regions-1.8.6 vs app/controllers/effective/regions_controller.rb in effective_regions-1.9.0

- old
+ new

@@ -1,28 +1,24 @@ module Effective class RegionsController < ApplicationController respond_to :html, :json layout false - if respond_to?(:before_action) - skip_before_action :verify_authenticity_token, only: :update - before_action :authenticate_user! if defined?(Devise) - else - skip_before_filter :verify_authenticity_token, only: :update - before_filter :authenticate_user! if defined?(Devise) - end + skip_before_action :verify_authenticity_token, only: :update + before_action(:authenticate_user!) if defined?(Devise) - skip_log_page_views quiet: true, only: [:snippet] if defined?(EffectiveLogging) + skip_log_page_views(quiet: true, only: [:snippet]) if defined?(EffectiveLogging) def edit - EffectiveRegions.authorize!(self, :edit, Effective::Region.new) + EffectiveResources.authorize!(self, :edit, Effective::Region.new) cookies['effective_regions_editting'] = {:value => params[:exit].presence || request.referrer, :path => '/'} # TODO: turn this into a cookie or something better. uri = URI.parse(Rack::Utils.unescape(request.url.sub('/edit', ''))) uri.query = [uri.query, "edit=true"].compact.join('&') + redirect_to uri.to_s end def update refresh_page = false @@ -35,19 +31,19 @@ to_save = nil # Which object, the regionable, or the region (if global) to save regionable, title = find_regionable(key) if regionable - EffectiveRegions.authorized?(self, :update, regionable) # can I update the regionable object? + EffectiveResources.authorized?(self, :update, regionable) # can I update the regionable object? region = regionable.regions.find { |region| region.title == title } - region ||= regionable.regions.build(:title => title) + region ||= regionable.regions.build(title: title) to_save = regionable else - region = Effective::Region.global.where(:title => title).first_or_initialize - EffectiveRegions.authorized?(self, :update, region) # can I update the global region? + region = Effective::Region.global.where(title: title).first_or_initialize + EffectiveResources.authorized?(self, :update, region) # can I update the global region? to_save = region end region.content = cleanup(vals[:content]) @@ -66,19 +62,19 @@ Effective::Menu.update_from_effective_regions!(menu_params) end response[:refresh] = true if refresh_page - render :json => response.to_json(), :status => 200 + render(json: response.to_json(), status: 200) return end - render :text => 'error', :status => :unprocessable_entity + render(text: 'error', status: :unprocessable_entity) end def snippet # This is a GET. CKEDITOR passes us data, we need to render the non-editable content - EffectiveRegions.authorize!(self, :edit, Effective::Region.new) + EffectiveResources.authorize!(self, :edit, Effective::Region.new) klass = "Effective::Snippets::#{region_params[:name].try(:classify)}".safe_constantize if klass.present? @snippet = klass.new(region_params[:data]) @@ -151,6 +147,5 @@ end end end end -