Class: Flexite::ConfigsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Flexite::ConfigsController
- Defined in:
- app/controllers/flexite/configs_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #reload ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/flexite/configs_controller.rb', line 17 def create result = ServiceFactory.instance.get(:config_create, Config::Form.new(config_params)).call if result.succeed? @node = result.record.to_tree_node @parent_id = config_params[:config_id] end service_flash(result) service_response(result) end |
#destroy ⇒ Object
44 45 46 47 |
# File 'app/controllers/flexite/configs_controller.rb', line 44 def destroy Config.destroy(params[:id]) head :ok end |
#edit ⇒ Object
29 30 31 |
# File 'app/controllers/flexite/configs_controller.rb', line 29 def edit @config_form = Config::Form.new(Config.find(params[:id]).attributes) end |
#index ⇒ Object
7 8 9 10 |
# File 'app/controllers/flexite/configs_controller.rb', line 7 def index @configs = Config.tree_view(params[:config_id]) @cache_key = "#{controller_name}/#{action_name}.#{request.format.symbol}/parent_id/#{params.fetch(:config_id, :root)}" end |
#new ⇒ Object
12 13 14 15 |
# File 'app/controllers/flexite/configs_controller.rb', line 12 def new parent_config = Config.where(id: params[:config_id], selectable: false).first @config_form = Config::Form.new(config_id: parent_config.present? ? parent_config.id : nil) end |
#reload ⇒ Object
49 50 51 52 53 |
# File 'app/controllers/flexite/configs_controller.rb', line 49 def reload Flexite.reload_root_cache flash[:success] = 'Cache was reloaded' render partial: 'flexite/shared/show_flash' end |
#update ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/flexite/configs_controller.rb', line 33 def update result = ServiceFactory.instance.get(:update_config, Config::Form.new(config_params)).call if result.succeed? @node = result.record.to_tree_node end service_flash(result) service_response(result) end |