Skip to content

Commit

Permalink
[DEMAD-126] Correcciones de default globalize
Browse files Browse the repository at this point in the history
  • Loading branch information
ajmorenoh committed May 17, 2021
1 parent 4696736 commit c26ffbc
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 7 deletions.
4 changes: 4 additions & 0 deletions app/controllers/admin/budget_groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ def destroy

def load_budget
@budget = Budget.find_by_slug_or_id! params[:budget_id]
rescue
@budget = nil
end

def load_group
@group = @budget.groups.find_by_slug_or_id! params[:id]
rescue
@group = nil
end

def groups_index
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def set_locale
session[:locale] = params[:locale]
end

session[:locale] ||= I18n.default_locale
session[:locale] ||= :es

locale = session[:locale]

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/management/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def set_locale
session[:locale] = params[:locale]
end

session[:locale] ||= I18n.default_locale
session[:locale] ||= :es

I18n.locale = session[:locale]
Globalize.locale = I18n.locale
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def proposal_notification_digest(user, notifications)
def user_invite(email)
@email_to = email

I18n.with_locale(I18n.default_locale) do
I18n.with_locale(:es) do
mail(to: @email_to, subject: t("mailers.user_invite.subject", org_name: Setting["org_name"]))
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/site_customization/content_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class SiteCustomization::ContentBlock < ApplicationRecord
validates :name, presence: true, uniqueness: { scope: :locale }, inclusion: { in: VALID_BLOCKS }

def self.block_for(name, locale)
locale ||= I18n.default_locale
locale ||= :es
find_by(name: name, locale: locale).try(:body)
end
end
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def email_required?
end

def locale
self[:locale] ||= I18n.default_locale.to_s
self[:locale] ||= :es.to_s
end

def confirmation_required?
Expand Down
4 changes: 3 additions & 1 deletion config/initializers/globalize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ module InstanceMethods
def save(*)
# Credit for this code belongs to Jack Tomaszewski:
# https://github.com/globalize/globalize/pull/578
Globalize.with_locale(Globalize.locale || I18n.default_locale) do
Globalize.with_locale(Globalize.locale || :es) do
super
end
rescue
super
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
require "selenium/webdriver"

Rails.application.load_tasks if Rake::Task.tasks.empty?
I18n.default_locale = :en
I18n.default_locale = :es

include Warden::Test::Helpers
Warden.test_mode!
Expand Down

0 comments on commit c26ffbc

Please sign in to comment.