Module: Scrivito::ControllerActions
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/cms/scrivito/controller_actions.rb
Overview
This module provides CMS controller actions. Include it in controller you want to make able to deliver +Obj+s.
Instance Method Summary collapse
-
#deliver_file ⇒ Object
private
Deliver a binary
Objby redirecting to its Obj#binary's url. -
#index ⇒ Object
Default action.
-
#on_scrivito_widget_error(widget, error) ⇒ Object
How to handle widget errors in
production.
Instance Method Details
#deliver_file ⇒ Object (private)
Deliver a binary Obj by redirecting to its Obj#binary's url.
Will respond with 404 if the Obj has no blob.
164 165 166 167 168 169 170 171 |
# File 'app/cms/scrivito/controller_actions.rb', line 164 def deliver_file if binary = @obj.binary binary_routing = BinaryRouting.new(request, scrivito_engine) redirect_to binary_routing.resolved_binary_url(binary), allow_other_host: true else render plain: 'Empty Blob', status: 404 end end |
#index ⇒ Object
Default action.
Delivers files directly if Obj is binary.
Otherwise the view is rendered.
37 38 39 |
# File 'app/cms/scrivito/controller_actions.rb', line 37 def index deliver_file if @obj.binary? end |
#on_scrivito_widget_error(widget, error) ⇒ Object
How to handle widget errors in production.
When an exception is raised from within a widget, the entire page is not available. Often, this is the case in production if the developer has forgotten to handle specific content scenarios such as empty date attributes, missing titles, unmanaged enum values, etc. but also for simple coding mistakes during development.
By default, Scrivito handles exceptions raised while rendering a widget by adding a placeholder text to the HTML indicating that the widget couldn't be rendered. In addition, the exception is logged alongside with its backtrace.
Override this method to adapt this behaviour.
The overridden method allows to:
- catch a widget error and replace it with an HTML placeholder.
- report a widget error to an external service like Honeybadger or Airbrake.
This method is not called if Rails is in the development or test environment.
In those environments, all widget errors are just raised.
|
|
# File 'app/cms/scrivito/controller_actions.rb', line 63
|