Sha256: 095cd741c732d0ae4b8f73bba9e187227d109cb846b30d239c235a758fcf819c

Contents?: true

Size: 1.83 KB

Versions: 6

Compression:

Stored size: 1.83 KB

Contents

EffectiveRegions.setup do |config|
  config.regions_table_name = :regions
  config.ck_assets_table_name = :ck_assets

  # Before Region Save Method
  #
  # This method is called when a User clicks the 'Save' button in the full screen editor.
  # It will be called once for each region immediately before the regions are saved to the database.
  #
  # This is not an ActiveRecord before_save callback and there is no way to cancel the save.
  #
  # This method is run on the controller.view_context, so you have access to all your regular
  # view helpers as well as the request object.
  #
  # The second argument, 'parent', will be the Effective::Region's parent regionable object, or the symbol :global
  #
  # If you are gsub'ing the region.content String value or altering the region.snippets Hash values,
  # those changes will not be immediately visible on the front-end.
  #
  # If you need the user to immediately see these changes, have your Proc or function return the symbol :refresh
  #
  # Returning the symbol :refresh will instruct javascript to perform a full page refresh after the Save is complete.
  #
  # Don't change the region.title, as this will orphan the region
  #
  # Use via Proc:
  #
  # config.before_save_method = Proc.new do |region, parent|
  #   region.content = region.content.gsub('force', 'horse') if region.title == 'body'
  #   :refresh
  # end
  #
  # Use via custom method:
  # config.before_save_method = :my_region_before_save_method
  #
  # And then in your application_controller.rb:
  #
  # def my_region_before_save_method(region, parent)
  #   if region.title == 'body' && request.fullpath == posts_path
  #     region.content = region.content.gsub('force', 'horse')
  #     :refresh
  #   end
  # end
  #
  # Or disable the callback completely:
  # config.before_save_method = false

  config.before_save_method = false
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
effective_regions-1.11.0 config/effective_regions.rb
effective_regions-1.10.3 config/effective_regions.rb
effective_regions-1.10.2 config/effective_regions.rb
effective_regions-1.10.1 config/effective_regions.rb
effective_regions-1.10.0 config/effective_regions.rb
effective_regions-1.9.0 config/effective_regions.rb