2012-10-24 32 views
0

使用Rails 3.使用數組我有以下幾點:在routes.rb中

# shop.rb 
SHOP_TYPES = %w(cafe restaurant station) 

# routes.rb 
resources :shops do 
    member do 
    get :nearby_cafes, :nearby_restaurants, :nearby_stations 
    end 
end 

而不是更新我routes.rb每次我的SHOP_TYPES陣列中添加其他成員,反正是有讀陣列中的routes.rb

謝謝。

+2

'Shop :: SHOP_TYPES'?所以:'get * Shop :: SHOP_TYPES' – apneadiving

回答

1
TYPES = :nearby_cafes, :nearby_restaurants, :nearby_stations 
.... 
get *TYPES 
+0

我不想重新定義'SHOP_TYPES'到'TYPES'。 – Victor