Ruby on rails RAILS-从URL中删除#.vvhszgervm

Ruby on rails RAILS-从URL中删除#.vvhszgervm,ruby-on-rails,sessionid,rails-i18n,Ruby On Rails,Sessionid,Rails I18n,我对RubyonRails的世界还很陌生 我正在尝试为我的应用程序设置i18n。我可以按照以下指南来做: 问题:当我点击像这样的链接时 <%= link_to image_tag("flags/en.png"), :locale=>'en'%> 如何避免此#.vvhszgervm出现在URL中 应用程序控制器 class ApplicationController < ActionController::Base # Prevent CSRF attacks by

我对RubyonRails的世界还很陌生

我正在尝试为我的应用程序设置i18n。我可以按照以下指南来做:

问题:当我点击像这样的链接时

<%= link_to image_tag("flags/en.png"), :locale=>'en'%>
如何避免此
#.vvhszgervm
出现在URL中

应用程序控制器

class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception
  before_action :set_locale



  def set_locale
    extracted_locale = params[:locale] || extract_locale_from_accept_language_header

    I18n.locale = (I18n::available_locales.include? extracted_locale.to_sym) ? 
                  extracted_locale : I18n.default_locale
  end

  def extract_locale_from_accept_language_header
    request.env['HTTP_ACCEPT_LANGUAGE'] ? request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first : 'pt'
  end

  def default_url_options(options = {})
    { locale: I18n.locale }.merge options
  end

end
class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception
  before_action :set_locale



  def set_locale
    extracted_locale = params[:locale] || extract_locale_from_accept_language_header

    I18n.locale = (I18n::available_locales.include? extracted_locale.to_sym) ? 
                  extracted_locale : I18n.default_locale
  end

  def extract_locale_from_accept_language_header
    request.env['HTTP_ACCEPT_LANGUAGE'] ? request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first : 'pt'
  end

  def default_url_options(options = {})
    { locale: I18n.locale }.merge options
  end

end
Rails.application.routes.draw do
  scope '/(:locale)', locale: /#{I18n.available_locales.join("|")}/ do
    root 'home#index'
  end
end