Class: AwesomeTranslations::HandlersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/awesome_translations/handlers_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



4
5
6
# File 'app/controllers/awesome_translations/handlers_controller.rb', line 4

def index
  @handlers = AwesomeTranslations::CacheDatabaseGenerator::Handler.order(:name)
end

#showObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/awesome_translations/handlers_controller.rb', line 26

def show
  @ransack_values = params[:q] || {
    with_translations: "only_with"
  }

  @ransack = @handler
    .groups
    .ransack(@ransack_values)

  @groups = @ransack
    .result
    .includes(handler_translations: :translation_key)
    .order(:name)

  filter_with_translations
  filter_with_missing_translations
end

#update_cacheObject



8
9
10
11
12
13
# File 'app/controllers/awesome_translations/handlers_controller.rb', line 8

def update_cache
  generator = AwesomeTranslations::CacheDatabaseGenerator.current
  generator.update_handlers

  redirect_back(fallback_location: :root)
end

#update_groups_cacheObject



15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/awesome_translations/handlers_controller.rb', line 15

def update_groups_cache
  generator = AwesomeTranslations::CacheDatabaseGenerator.current
  generator.update_handlers do |handler_model|
    next unless handler_model.identifier == @handler.identifier

    generator.update_groups_for_handler(handler_model)
  end

  redirect_back(fallback_location: :root)
end