Class: Rosetta::DatabaseRepository::PhrasesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Rosetta::DatabaseRepository::PhrasesController
- Defined in:
- app/controllers/rosetta/database_repository/phrases_controller.rb
Instance Method Summary collapse
Instance Method Details
#build_phrase ⇒ Object
28 29 30 31 32 |
# File 'app/controllers/rosetta/database_repository/phrases_controller.rb', line 28 def build_phrase @phrase.attributes = params&.permit( :value ) || {} end |
#load_or_create_phrase ⇒ Object
20 21 22 23 24 25 26 |
# File 'app/controllers/rosetta/database_repository/phrases_controller.rb', line 20 def load_or_create_phrase key = params[:id] locale = I18n.locale @phrase = Translation.find_by(key: key, locale: locale) || Translation.new(key: key, locale: locale) end |
#update ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/rosetta/database_repository/phrases_controller.rb', line 7 def update load_or_create_phrase build_phrase if @phrase.save I18n.backend.reload! else flash[:rosetta_alert] = 'Your new translation not saved.' end redirect_to params[:current_path] end |