Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将 'about' 路由到 'abouts/1'
我试过这个:
match 'about' => 'abouts#show/1', :via => get
它不起作用。有任何想法吗?
仅从路由中删除 1 并直接在控制器方法中检索您想要的记录怎么样?
# routes.rb match 'about' => 'abouts#show', :via => get # abouts_controller.rb def show @about = About.find(1) end
怎么样:
match 'about' => 'abouts#show', :via => :get, :defaults => {:id => 1}