Class: Compony::Components::New
- Inherits:
-
WithForm
- Object
- Compony::Component
- WithForm
- Compony::Components::New
- Includes:
- Compony::ComponentMixins::Resourceful
- Defined in:
- lib/compony/components/new.rb
Overview
This component is used for the Rails new and create paradigm. Performs update when the form is submitted.
Instance Attribute Summary
Attributes included from Compony::ComponentMixins::Resourceful
#data, #global_after_assign_attributes_block, #global_after_load_data_block, #global_assign_attributes_block, #global_load_data_block, #global_store_data_block
Attributes inherited from Compony::Component
#comp_opts, #content_blocks, #parent_comp
DSL collapse
-
#on_create_failed_respond { ... } ⇒ void
DSL method Overrides the response issued when the create failed (
@create_succeededis not true). -
#on_created { ... } ⇒ void
DSL method Sets an optional hook evaluated (with backfire) after a successful create but before responding.
-
#on_created_redirect_path { ... } ⇒ void
DSL method Overrides the redirect target used by the default #on_created_respond (keeping the default flash).
-
#on_created_respond { ... } ⇒ void
DSL method Overrides the response issued after a successful create.
Methods included from Compony::ComponentMixins::Resourceful
#after_assign_attributes, #after_load_data, #assign_attributes, #data_class, #initialize, #load_data, #resourceful?, #store_data
Methods inherited from WithForm
#form_cancancan_action, #form_comp, #form_comp_class, #initialize, #submit_path, #submit_verb
Methods inherited from Compony::Component
#before_render, comp_name, #content, #exposed_intents, family_name, #id, #id_path, #id_path_hash, #initialize, #inspect, #param_name, #path, #remove_content, #remove_content!, #render, #resourceful?, #root_comp, #root_comp?, setup, #sub_comp
Instance Method Details
#on_create_failed_respond { ... } ⇒ void
This method returns an undefined value.
DSL method
Overrides the response issued when the create failed (@create_succeeded is not true).
The default logs the errors with level warn and re-renders the component with HTTP 422 so the form shows errors.
120 121 122 |
# File 'lib/compony/components/new.rb', line 120 def on_create_failed_respond(&block) @on_create_failed_respond_block = block end |
#on_created { ... } ⇒ void
This method returns an undefined value.
DSL method
Sets an optional hook evaluated (with backfire) after a successful create but before responding.
Suitable for post-create side effects (like an after_create that only fires when this component created the record).
Do not redirect or render here - use #on_created_respond / #on_created_redirect_path for that.
90 91 92 |
# File 'lib/compony/components/new.rb', line 90 def on_created(&block) @on_created_block = block end |
#on_created_redirect_path { ... } ⇒ void
This method returns an undefined value.
DSL method Overrides the redirect target used by the default #on_created_respond (keeping the default flash). Defaults to the data's Show, the owner's Show, or the data's Index.
110 111 112 |
# File 'lib/compony/components/new.rb', line 110 def on_created_redirect_path(&block) @on_created_redirect_path_block = block end |
#on_created_respond { ... } ⇒ void
This method returns an undefined value.
DSL method Overrides the response issued after a successful create. The default shows a flash and redirects to #on_created_redirect_path. If you override this, #on_created_redirect_path is no longer called.
100 101 102 |
# File 'lib/compony/components/new.rb', line 100 def on_created_respond(&block) @on_created_respond_block = block end |