0

在迁移之前,网站完全没问题。现在我们已经迁移到一个新的服务器,网站开始显示一些链接的这种错误:http: //babybum.proj.dev.doo.is/sao-paulo/planta

这是公平控制器中“区域”的定义

    def area
       @area_name = BB_MENU_AREAS_SLUG.select {|k, v| v == params[:area]}.keys.first
       if @area_name
          @area = Snippet.find_by_identifier([params[:fair_location], @area_name.to_s].join('-'))
       else
          redirect_to root_path
       end
    end

BB_AREAS_SLUG 的片段

BB_AREAS = {
:about          => {:link => "quem somos", :slug => "quem-somos"},
:expositors     => {:link => "expositores",:slug => "expositores"},
:map            => {:link => "planta", :slug => "planta"},
:activities     => {:link => "atividades",:slug => "atividades"},
:address        => {:link => "como chegar",:slug => "como-chegar"},
:support        => {:link => "apoio", :slug => "apoio"},
:optin          => {:link => "cadastro",:slug => "cadastro"},
:how_expositors => {:link => "como expor",:slug => "como-expor"},
:press          => {:link => "imprensa",:slug => "imprensa"},
:contact        => {:link => "contato",:slug => "contato"},
}

BB_MENU_AREAS       = BB_AREAS.each_with_object({}) { |(k, v), h| h[k] = v[:link]}
BB_MENU_AREAS_SLUG  = BB_AREAS.each_with_object({}) { |(k, v), h| h[k] = v[:slug]}

有人可以帮助我吗?

谢谢

4

1 回答 1

2

可能问题出在另一个 Ruby 版本上。我没有 1.8 来测试它,但是在旧服务器上你有 1.8.x,现在是 1.9.x。你需要改变

@area_name = BB_MENU_AREAS_SLUG.select {|k, v| v == params[:area]}.keys.first

@area_name = Hash[BB_MENU_AREAS_SLUG.select {|k, v| v == params[:area]}].keys.first

甚至将其折射为:

@area_name = BB_MENU_AREAS_SLUG.find { |_, v| v == params[:area] }.first
于 2013-02-19T13:04:43.900 回答