Rails:这条路线出了什么问题?

时间:2010-09-22 10:54:33

标签: ruby-on-rails rest ruby-on-rails-3 routes

由于某些奇怪的原因,cardsets_path('my')生成“/ cardsets.my”而不是“/ cardsets / my”。请解释原因?

配置/ routes.rb中:

match '/cardsets/:type', :to => 'cardsets#index', :requirements => { :type => /my|public/ }, :as => 'cardsets'

resources :users do
  resources :cardsets do
  end
end

rake routes:

cardsets /cardsets/:type(.:format) {:controller=>"cardsets", :action=>"index"}

1 个答案:

答案 0 :(得分:3)

不应该是

cardsets_path(:type => 'my')

但是,type是rails中的保留字。