Class: Weeler::TranslationsController
- Inherits:
-
ConfigurationController
- Object
- ApplicationController
- ApplicationController
- BaseController
- ConfigurationController
- Weeler::TranslationsController
- Defined in:
- app/controllers/weeler/translations_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #export ⇒ Object
- #import ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/weeler/translations_controller.rb', line 18 def create @translation = I18n::Backend::Weeler::Translation.new(translation_params) if @translation.save Setting.i18n_updated_at = Time.now redirect_to ({ action: :edit, id: @translation }), flash: { success: "Translation saved." } else flash.now[:error] = "Errors in saving." render :edit end end |
#destroy ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'app/controllers/weeler/translations_controller.rb', line 43 def destroy @translation = I18n::Backend::Weeler::Translation.find(params[:id]) @translation.destroy Setting.i18n_updated_at = Time.now redirect_to ({ action: :index }), flash: {success: "Translation succesfully removed."} end |
#edit ⇒ Object
14 15 16 |
# File 'app/controllers/weeler/translations_controller.rb', line 14 def edit @translation = I18n::Backend::Weeler::Translation.find(params[:id]) end |
#export ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/weeler/translations_controller.rb', line 52 def export respond_to do |format| format.xlsx do outstrio = StringIO.new outstrio.write(translations_by_params.as_xlsx_package.to_stream.read) send_data(outstrio.string, filename: "translations" + '.xlsx') end end end |
#import ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/controllers/weeler/translations_controller.rb', line 62 def import if params[:file].present? I18n::Backend::Weeler::Translation.import params[:file] Setting.i18n_updated_at = Time.now redirect_to ({ action: :index }), flash: {success: "Translations succesfully imported."} else redirect_to ({ action: :index }), flash: {success: "No file choosen"} end end |
#index ⇒ Object
4 5 6 7 8 |
# File 'app/controllers/weeler/translations_controller.rb', line 4 def index @translations = translations_by_params @translations = @translations.page(params[:page]).per(20) @groups = I18n::Backend::Weeler::Translation.groups end |
#new ⇒ Object
10 11 12 |
# File 'app/controllers/weeler/translations_controller.rb', line 10 def new @translation = I18n::Backend::Weeler::Translation.new end |
#update ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/controllers/weeler/translations_controller.rb', line 30 def update @translation = I18n::Backend::Weeler::Translation.find(params[:id]) if @translation.update(translation_params) Setting.i18n_updated_at = Time.now redirect_to ({ action: :edit, id: @translation }), flash: { success: "Translation updated." } else flash.now[:error] = "Errors in updating." render :edit end end |