diff --git a/Gemfile b/Gemfile index a0784a635ea..e3cd099625c 100644 --- a/Gemfile +++ b/Gemfile @@ -20,7 +20,7 @@ gem "devise-async", "~> 1.0.0" gem "devise_security_extension", git: "https://github.com/phatworx/devise_security_extension.git" #, "~> 0.10" gem "foundation-rails", "~> 6.4.3.0" gem "foundation_rails_helper", "~> 2.0.0" -gem "globalize", "~> 5.2.0" +gem "globalize", "5.2.0" gem "globalize-accessors", "~> 0.2.1" gem "graphiql-rails", "~> 1.4.1" gem "graphql", "~> 1.7.8" diff --git a/Gemfile.lock b/Gemfile.lock index 2e583920a16..32dec0fa812 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -584,7 +584,7 @@ DEPENDENCIES faker (~> 1.8.7) foundation-rails (~> 6.4.3.0) foundation_rails_helper (~> 2.0.0) - globalize (~> 5.2.0) + globalize (= 5.2.0) globalize-accessors (~> 0.2.1) graphiql-rails (~> 1.4.1) graphql (~> 1.7.8) diff --git a/app/controllers/admin/budget_groups_controller.rb b/app/controllers/admin/budget_groups_controller.rb index f675a140e8c..0b38567adef 100644 --- a/app/controllers/admin/budget_groups_controller.rb +++ b/app/controllers/admin/budget_groups_controller.rb @@ -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 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 10a4f3622e4..9297ed2e838 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -46,7 +46,7 @@ def set_locale session[:locale] = params[:locale] end - session[:locale] ||= I18n.default_locale + session[:locale] ||= :es locale = session[:locale] diff --git a/app/controllers/budgets/groups_controller.rb b/app/controllers/budgets/groups_controller.rb index 32d4fc5759a..a1685441798 100644 --- a/app/controllers/budgets/groups_controller.rb +++ b/app/controllers/budgets/groups_controller.rb @@ -19,6 +19,8 @@ def load_budget def load_group @group = @budget.groups.find_by_slug_or_id! params[:id] + rescue + @group = nil end end diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index 159f1d4cefe..629664ee518 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -135,6 +135,8 @@ def investment_params def load_investment @investment = @budget.investments.find(params["id"]) + rescue + @investment = nil end def load_ballot diff --git a/app/controllers/management/base_controller.rb b/app/controllers/management/base_controller.rb index fa7e0b4d45d..f52d4f017a6 100644 --- a/app/controllers/management/base_controller.rb +++ b/app/controllers/management/base_controller.rb @@ -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 diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index fed493655fe..86ae826c003 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -68,6 +68,8 @@ def load_community def load_topic @topic = Topic.find(params[:id]) + rescue + @topic = nil end def load_rank diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index ca7a0a2c158..d34da7a2333 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -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 diff --git a/app/models/concerns/sluggable.rb b/app/models/concerns/sluggable.rb index bdcdff85662..5530618a0de 100644 --- a/app/models/concerns/sluggable.rb +++ b/app/models/concerns/sluggable.rb @@ -10,6 +10,8 @@ def self.find_by_slug_or_id(slug_or_id) def self.find_by_slug_or_id!(slug_or_id) find_by_slug(slug_or_id) || find(slug_or_id) + rescue + find(slug_or_id) end end diff --git a/app/models/site_customization/content_block.rb b/app/models/site_customization/content_block.rb index 2219ef5d466..0ae8be25596 100644 --- a/app/models/site_customization/content_block.rb +++ b/app/models/site_customization/content_block.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 3b1ee76cacc..185f34a10f0 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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? diff --git a/app/views/communities/show.html.erb b/app/views/communities/show.html.erb index faeccd8bc8b..c71f3e652e5 100644 --- a/app/views/communities/show.html.erb +++ b/app/views/communities/show.html.erb @@ -36,7 +36,7 @@
- <%= link_to content_tag(:span, nil, class: "icon-angle-left") + "Volver", borought_debates_path(geozone: Proposal.find_by(community_id: @community.id).geozone_id) %> + <%= link_to content_tag(:span, nil, class: "icon-angle-left") + "Volver", borought_debates_path(geozone: Proposal.find_by(community_id: @community.id).try(:geozone_id)) %> <%= render "topics/topics", topics: @topics %>
<%= paginate @topics %> diff --git a/app/views/custom/proposals/show.html.erb b/app/views/custom/proposals/show.html.erb index 6fb664a4e7d..a7128b42050 100644 --- a/app/views/custom/proposals/show.html.erb +++ b/app/views/custom/proposals/show.html.erb @@ -21,7 +21,7 @@
<%unless params[:author_id].blank? %> - <%= back_link_to user_path(current_user) %> + <%= back_link_to user_path(current_user) if !current_user.blank? %>
<%if @proposal.previous(params[:author_id]) %> <%= link_to proposal_path(@proposal.previous(params[:author_id]), author_id: params[:author_id]) do %> diff --git a/config/initializers/globalize.rb b/config/initializers/globalize.rb index d5834f2171d..f067a25ebc7 100644 --- a/config/initializers/globalize.rb +++ b/config/initializers/globalize.rb @@ -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 diff --git a/db/migrate/20210511081034_change_column_name_users.rb b/db/migrate/20210511081034_change_column_name_users.rb deleted file mode 100644 index 0dd0f8c18ab..00000000000 --- a/db/migrate/20210511081034_change_column_name_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class ChangeColumnNameUsers < ActiveRecord::Migration[5.0] - def change - rename_column :users, :name, :first_name - end -end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 357c37722b8..d259a656972 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -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!