Class: Alchemy::Admin::NodesController

Inherits:
ResourcesController show all
Includes:
CurrentLanguage
Defined in:
app/controllers/alchemy/admin/nodes_controller.rb

Constant Summary

Constants inherited from ResourcesController

ResourcesController::COMMON_SEARCH_FILTER_EXCLUDES

Instance Method Summary collapse

Methods inherited from ResourcesController

#edit, #resource_filters, #resource_filters_for_select, #resource_handler, #resource_has_deprecated_filters, #resource_has_filters, #show, #update

Methods included from ResourcesHelper

#contains_relations?, #edit_resource_path, #new_resource_path, #render_attribute, #render_resources, #resource_attribute_field_options, #resource_has_tags, #resource_instance_variable, #resource_model, #resource_name, #resource_path, #resource_relations_names, #resource_scope, #resource_url_proxy, #resource_window_size, #resources_instance_variable, #resources_path, #sortable_resource_header_column

Methods inherited from BaseController

#leave

Methods included from Modules

included, #module_definition_for, register_module

Methods included from Alchemy::AbilityHelper

#current_ability

Methods included from ConfigurationMethods

#configuration, #multi_language?, #multi_site?, #prefix_locale?

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/alchemy/admin/nodes_controller.rb', line 19

def create
  if turbo_frame_request?
    @page = Alchemy::Page.find(resource_params[:page_id])
    @node = @page.nodes.build(resource_params)
    if @node.valid?
      @node.save
      flash_notice_for_resource_action(:create)
    else
      flash[:error] = @node.errors.full_messages.join(", ")
    end
  else
    super
  end
end

#destroyObject



34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/alchemy/admin/nodes_controller.rb', line 34

def destroy
  if turbo_frame_request?
    @node = Alchemy::Node.find(params[:id])
    @page = @node.page
    @page.nodes.destroy(@node)
    flash_notice_for_resource_action(:destroy)
  else
    super
  end
end

#indexObject



8
9
10
# File 'app/controllers/alchemy/admin/nodes_controller.rb', line 8

def index
  @root_nodes = Node.language_root_nodes
end

#newObject



12
13
14
15
16
17
# File 'app/controllers/alchemy/admin/nodes_controller.rb', line 12

def new
  @node = Node.new(
    parent_id: params[:parent_id],
    language: @current_language
  )
end