Add Globalize to Milestones

This commit is contained in:
rgarcia
2018-04-10 13:15:36 +02:00
committed by iagirre
parent 1b52ecc9ec
commit f7486b9238
15 changed files with 265 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
class Admin::BudgetInvestmentMilestonesController < Admin::BaseController
include Translatable
before_action :load_budget_investment, only: [:index, :new, :create, :edit, :update, :destroy]
before_action :load_budget_investment_milestone, only: [:edit, :update, :destroy]
@@ -46,7 +47,8 @@ class Admin::BudgetInvestmentMilestonesController < Admin::BaseController
documents_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
attributes = [:title, :description, :publication_date, :budget_investment_id,
image_attributes: image_attributes, documents_attributes: documents_attributes]
params.require(:budget_investment_milestone).permit(*attributes)
params.require(:budget_investment_milestone).permit(*attributes, translation_params)
end
def load_budget_investment

View File

@@ -0,0 +1,19 @@
module Translatable
extend ActiveSupport::Concern
included do
before_action :set_translation_locale
end
private
def translation_params
Budget::Investment::Milestone.globalize_attribute_names.
select { |k, v| params[:budget_investment_milestone].include?(k.to_sym) && params[:budget_investment_milestone][k].present? }
end
def set_translation_locale
Globalize.locale = I18n.locale
end
end