Class: Alchemy::Admin::LanguagesController

Inherits:
ResourcesController show all
Defined in:
app/controllers/alchemy/admin/languages_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



21
22
23
24
25
26
27
28
29
# File 'app/controllers/alchemy/admin/languages_controller.rb', line 21

def create
  @language = Alchemy::Language.new(resource_params)
  if @language.save
    flash[:notice] = Alchemy.t("Language successfully created")
    do_redirect_to alchemy.admin_pages_path(language_id: @language)
  else
    render :new
  end
end

#destroyObject



31
32
33
34
35
36
37
38
# File 'app/controllers/alchemy/admin/languages_controller.rb', line 31

def destroy
  if @language.destroy
    flash[:notice] = Alchemy.t("Language successfully removed")
  else
    flash[:warning] = @language.errors.full_messages.to_sentence
  end
  do_redirect_to alchemy.admin_languages_path
end

#indexObject



8
9
10
11
12
# File 'app/controllers/alchemy/admin/languages_controller.rb', line 8

def index
  @query = Language.on_site(@current_site).ransack(search_filter_params[:q])
  @query.sorts = default_sort_order if @query.sorts.empty?
  @languages = @query.result.page(params[:page] || 1).per(items_per_page)
end

#newObject



14
15
16
17
18
19
# File 'app/controllers/alchemy/admin/languages_controller.rb', line 14

def new
  @language = Language.new(
    site: @current_site,
    page_layout: Config.get(:default_language)["page_layout"]
  )
end

#switchObject



40
41
42
43
44
# File 'app/controllers/alchemy/admin/languages_controller.rb', line 40

def switch
  @language = set_alchemy_language(params[:language_id])
  session[:alchemy_language_id] = @language.id
  do_redirect_to request.referer || alchemy.admin_dashboard_path
end