diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d53225a..c5968d1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -19,9 +19,18 @@ class ApplicationController < ActionController::Base end def set_locale - compatible_locale = http_accept_language.compatible_language_from(I18n.available_locales) - unless compatible_locale.nil? - I18n.locale = compatible_locale + unless params[:locale].nil? + I18n.locale = params[:locale] + else + compatible_locale = http_accept_language.compatible_language_from(I18n.available_locales) + unless compatible_locale.nil? + I18n.locale = compatible_locale + end end end + + # This happens after the *_url *_path helpers + def default_url_options(options = {}) + { locale: I18n.locale == I18n.default_locale ? nil : I18n.locale }.merge options + end end diff --git a/app/controllers/concerns/ownership_authentication.rb b/app/controllers/concerns/ownership_authentication.rb index 9c8f897..cdb1db0 100644 --- a/app/controllers/concerns/ownership_authentication.rb +++ b/app/controllers/concerns/ownership_authentication.rb @@ -65,7 +65,7 @@ module OwnershipAuthentication def check_reading_group_ownership(id) if current_user.reading_group_ownerships.find_by_reading_group_id(id).nil? respond_to do |format| - format.html { redirect_to reading_group_url(id), notice: "You're not allowed to do this operation" } + format.html { redirect_to reading_group_url(id: id), notice: "You're not allowed to do this operation" } format.json { head :no_content } end end @@ -76,7 +76,7 @@ module OwnershipAuthentication def check_kalibro_configuration_ownership(id) if current_user.kalibro_configuration_ownerships.find_by_kalibro_configuration_id(id).nil? respond_to do |format| - format.html { redirect_to kalibro_configurations_url(id), notice: "You're not allowed to do this operation" } + format.html { redirect_to kalibro_configurations_url(id: id), notice: "You're not allowed to do this operation" } format.json { head :no_content } end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 82737de..21b6dd2 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -63,7 +63,7 @@
  • <%= link_to KalibroConfiguration.model_name.human, kalibro_configurations_path %>
  • <%= link_to ReadingGroup.model_name.human, reading_groups_path %>
  • -