Class: Lit::LocalizationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Lit::LocalizationsController
- Defined in:
- app/controllers/lit/localizations_controller.rb
Instance Method Summary collapse
- #change_completed ⇒ Object
- #edit ⇒ Object
- #previous_versions ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#change_completed ⇒ Object
33 34 35 36 |
# File 'app/controllers/lit/localizations_controller.rb', line 33 def change_completed @localization.toggle(:is_changed).save! respond_to :js end |
#edit ⇒ Object
10 11 12 13 14 15 |
# File 'app/controllers/lit/localizations_controller.rb', line 10 def edit @localization.translated_value = @localization.translation respond_to do |format| format.js end end |
#previous_versions ⇒ Object
38 39 40 41 |
# File 'app/controllers/lit/localizations_controller.rb', line 38 def previous_versions @versions = @localization.versions.order(created_at: :desc) respond_to :js end |
#show ⇒ Object
6 7 8 |
# File 'app/controllers/lit/localizations_controller.rb', line 6 def show render json: { value: @localization.translation } end |
#update ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/controllers/lit/localizations_controller.rb', line 17 def update # Wrapping it in a transaction leverages the fact that @localization's # :after_commit callback is then executed AFTER whatever's done in # #after_update_operations. So it'll first set :is_changed to true # and then it will be properly read in the cache setting routine. @localization.transaction do after_update_operations if @localization.update(clear_params) end respond_to do |f| f.js f.json do render json: { value: @localization.reload.translation } end end end |