0
Rails 3.2。在这里,我想指示所有http://domain.dev/toys
只显示所有shops
其中shop_type
(在我的表格栏中)是toys
。通过路径参数
# routes.rb
resources :shops
match 'toys' => 'shops#index', :as => :toys, :via => :get, :constraints => {:shop_type => 'toys'}
# shops_controller.rb
def index
@shops = Shop.find(:all)
end
我做错了什么?谢谢。
心灵t o分享一些想法如何改善它? – Victor
@Victor您需要使用适当的商店类型进行查找 - 不知道最干净的方法是什么,但最简单的方法是创建一个方法,然后调用它并呈现相应的模板。 –