Class: Flexite::EntriesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Flexite::EntriesController
- Defined in:
- app/controllers/flexite/entries_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #destroy_array_entry ⇒ Object
- #edit ⇒ Object
- #new ⇒ Object
- #new_array_entry ⇒ Object
- #select_type ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/flexite/entries_controller.rb', line 12 def create klass = entry_params[:type].constantize form = klass.form(entry_params) result = ServiceFactory.instance.get(klass.service(:create), form).call if result.succeed? @entry = result.data[:record] @entry_form = @entry.class.form(@entry.form_attributes) end service_flash(result) service_response(result) end |
#destroy ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/flexite/entries_controller.rb', line 59 def destroy klass = params[:type].constantize form = klass.form(id: params[:id]) result = ServiceFactory.instance.get(klass.service(:destroy), form).call if result.succeed? @parent_id = result.data[:parent_id] end service_flash(result) service_response(result) end |
#destroy_array_entry ⇒ Object
52 53 54 55 56 57 |
# File 'app/controllers/flexite/entries_controller.rb', line 52 def destroy_array_entry result = ServiceFactory.instance.get(:destroy_array_entry, Entry.form(params)).call @selector = params[:selector] service_flash(result) service_response(result) end |
#edit ⇒ Object
26 27 28 29 |
# File 'app/controllers/flexite/entries_controller.rb', line 26 def edit @entry = Entry.find(params[:id]) @entry_form = @entry.class.form(@entry.form_attributes) end |
#new ⇒ Object
7 8 9 10 |
# File 'app/controllers/flexite/entries_controller.rb', line 7 def new klass = entry_params[:type].constantize @entry_form = klass.form(entry_params) end |
#new_array_entry ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/flexite/entries_controller.rb', line 39 def new_array_entry klass = params[:type].constantize @form_options = [params[:prefix]] if (@form_index = params[:form_index]).present? @form_options << { index: @form_index } end @parent_id = params[:parent_id] @index = params[:index] @entry_form = klass.form(klass.new.form_attributes) end |
#select_type ⇒ Object
72 73 74 |
# File 'app/controllers/flexite/entries_controller.rb', line 72 def select_type @config = Config.find(params[:parent_id]) end |
#update ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/controllers/flexite/entries_controller.rb', line 31 def update klass = entry_params[:type].constantize form = klass.form(entry_params) result = ServiceFactory.instance.get(klass.service(:update), form).call service_flash(result) service_response(result) end |