2012-03-13 5 views
0

URLのセットを手動でリダイレクトする必要がありますが、現在行っているものよりも効率的な方法(行数)が必要になるようです。このルートブロックをリファクタリングしますか?

match "/articles/care" => redirect("/articles/category/care") 
match "/articles/food-diet" => redirect("/articles/category/food-diet") 
match "/articles/basics" => redirect("/articles/category/basics") 
match "/articles/training" => redirect("/articles/category/training") 
match "/articles/recipes" => redirect("/articles/category/recipes") 
match "/articles/life" => redirect("/articles/category/life") 

答えて

3

これを試してみてください:

for category in %w{ care food-diet training recipes life } 
    match "/articles/#{category}" => redirect("/articles/category/#{category}") 
end 
関連する問題