Class: Locomotive::ActionController::PublicResponder
- Inherits:
-
ActionController::Responder
- Object
- ActionController::Responder
- Locomotive::ActionController::PublicResponder
- Defined in:
- lib/locomotive/action_controller/public_responder.rb
Instance Method Summary collapse
- #api_location ⇒ Object
- #callback_url(state) ⇒ Object
-
#content_entry ⇒ Object
get the content entry from the controller.
- #error_location ⇒ Object
- #navigation_behavior(error) ⇒ Object
- #navigation_error_behavior ⇒ Object
- #navigation_success_behavior ⇒ Object
- #page_path ⇒ Object
- #success_location ⇒ Object
Instance Method Details
#api_location ⇒ Object
15 16 17 |
# File 'lib/locomotive/action_controller/public_responder.rb', line 15 def api_location success_location end |
#callback_url(state) ⇒ Object
64 65 66 |
# File 'lib/locomotive/action_controller/public_responder.rb', line 64 def callback_url(state) self.controller.params[:"#{state}_callback"] end |
#content_entry ⇒ Object
get the content entry from the controller
56 57 58 |
# File 'lib/locomotive/action_controller/public_responder.rb', line 56 def content_entry self.controller.instance_variable_get :@entry end |
#error_location ⇒ Object
47 48 49 |
# File 'lib/locomotive/action_controller/public_responder.rb', line 47 def error_location callback_url(:error) || (page_path ? request.path : '/') end |
#navigation_behavior(error) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/locomotive/action_controller/public_responder.rb', line 5 def (error) if get? raise error elsif has_errors? && default_action else end end |
#navigation_error_behavior ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/locomotive/action_controller/public_responder.rb', line 19 def if error_location =~ %r(^http://) # simple redirection for outside urls redirect_to error_location else path = page_path ? page_path : extract_locale_and_path(error_location) # render the locomotive page assigns = {} if content_entry slug = content_entry.content_type.slug.singularize entry = content_entry.to_presenter(include_errors: true).as_json assigns[slug] = entry end self.controller.send :render_locomotive_page, path, assigns end end |
#navigation_success_behavior ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/locomotive/action_controller/public_responder.rb', line 39 def # store in session the newly created content entry self.controller.flash['submitted_entry_id'] = self.content_entry.try(:_id).try(:to_s) # redirect to a locomotive page redirect_to success_location end |
#page_path ⇒ Object
60 61 62 |
# File 'lib/locomotive/action_controller/public_responder.rb', line 60 def page_path self.controller.params[:path] end |
#success_location ⇒ Object
51 52 53 |
# File 'lib/locomotive/action_controller/public_responder.rb', line 51 def success_location callback_url(:success) || (page_path ? request.path : '/') end |