Class: TranslationClient::TranslationsController
Instance Method Summary
collapse
#my_method
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
58
59
60
61
62
63
64
65
66
|
# File 'app/controllers/translation_client/translations_controller.rb', line 58
def method_missing(m, *args, &block)
if m.to_s.match(/i18n_backend_active_record_translation/) && m.to_s.match(/path|url/)
translation_client.send m.to_s.gsub('i18n_backend_active_record_translation', 'translation'), *args, &block
elsif m.to_s.match(/path|url/) && main_app.respond_to?(m)
main_app.send m, *args, &block
else
super m, *args, &block
end
end
|
Instance Method Details
#create ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/translation_client/translations_controller.rb', line 16
def create
@translation = Translation.new(params[:i18n_backend_active_record_translation])
if @translation.save
I18n.backend.reload!
redirect_to [:edit, @translation], notice: t('general.form.successfully_created')
else
render :new
end
end
|
#destroy ⇒ Object
41
42
43
44
45
46
|
# File 'app/controllers/translation_client/translations_controller.rb', line 41
def destroy
@translation.destroy
I18n.backend.reload!
redirect_to translation_client.translations_path, notice: t('general.form.destroyed')
end
|
#edit ⇒ Object
28
29
|
# File 'app/controllers/translation_client/translations_controller.rb', line 28
def edit
end
|
#index ⇒ Object
8
9
10
|
# File 'app/controllers/translation_client/translations_controller.rb', line 8
def index
@translations = Translation.order('translation_key ASC')
end
|
#new ⇒ Object
12
13
14
|
# File 'app/controllers/translation_client/translations_controller.rb', line 12
def new
@translation = Translation.new(params[:i18n_backend_active_record_translation])
end
|
#resource ⇒ Object
48
49
50
|
# File 'app/controllers/translation_client/translations_controller.rb', line 48
def resource
@translation
end
|
#update ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/translation_client/translations_controller.rb', line 31
def update
if @translation.update_attributes(params[:i18n_backend_active_record_translation])
I18n.backend.reload!
redirect_to [:edit, @translation], notice: t('general.form.successfully_updated')
else
render :edit
end
end
|