在迁移之前,网站完全没问题。现在我们已迁移到新服务器,网站开始显示某些链接的这类错误: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]}
有人可以帮助我吗?
谢谢
答案 0 :(得分: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