Add Globalize to Milestones
This commit is contained in:
@@ -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
|
||||
|
||||
19
app/controllers/concerns/translatable.rb
Normal file
19
app/controllers/concerns/translatable.rb
Normal 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
|
||||
Reference in New Issue
Block a user