Make budgets translatable

This commit is contained in:
Julian Herrero
2019-01-19 15:49:18 +01:00
parent 2eb2839ab0
commit d76782f150
11 changed files with 129 additions and 16 deletions

View File

@@ -26,14 +26,17 @@ end
section "Creating Budgets" do
Budget.create(
name: "#{I18n.t('seeds.budgets.budget')} #{Date.current.year - 1}",
currency_symbol: I18n.t('seeds.budgets.currency'),
phase: 'finished'
name_en: "#{I18n.t("seeds.budgets.budget", locale: :en)} #{Date.current.year - 1}",
name_es: "#{I18n.t("seeds.budgets.budget", locale: :es)} #{Date.current.year - 1}",
currency_symbol: I18n.t("seeds.budgets.currency"),
phase: "finished"
)
Budget.create(
name: "#{I18n.t('seeds.budgets.budget')} #{Date.current.year}",
currency_symbol: I18n.t('seeds.budgets.currency'),
phase: 'accepting'
name_en: "#{I18n.t("seeds.budgets.budget", locale: :en)} #{Date.current.year}",
name_es: "#{I18n.t("seeds.budgets.budget", locale: :es)} #{Date.current.year}",
currency_symbol: I18n.t("seeds.budgets.currency"),
phase: "accepting"
)
Budget.all.each do |budget|

View File

@@ -0,0 +1,16 @@
class AddBudgetTranslations < ActiveRecord::Migration
def self.up
Budget.create_translation_table!(
{
name: :string
},
{ migrate_data: true }
)
end
def self.down
Budget.drop_translation_table!
end
end

View File

@@ -266,6 +266,17 @@ ActiveRecord::Schema.define(version: 20190205131722) do
t.datetime "updated_at", null: false
end
create_table "budget_translations", force: :cascade do |t|
t.integer "budget_id", null: false
t.string "locale", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "name"
end
add_index "budget_translations", ["budget_id"], name: "index_budget_translations_on_budget_id", using: :btree
add_index "budget_translations", ["locale"], name: "index_budget_translations_on_locale", using: :btree
create_table "budget_valuator_assignments", force: :cascade do |t|
t.integer "valuator_id"
t.integer "investment_id"