我很难理解rails中的路由。我有一个包含大量投资组合页面的文件夹。每个都是.html.erb格式,我为每个格式制作了一条获取路线。
我该如何简化?
Location: app>views
portfolio/uniquename1.html.erb
portfolio/rexpage.html.erb
portfolio/armstrong.html.erb
portfolio/occupy.html.erb
portfolio/fancythat.html.erb
等...
路线如下:
NewPortfolio::Application.routes.draw do
get "portfolio/uniquename1"
get "portfolio/rexpage"
get "portfolio/armstrong"
get "portfolio/occupy"
get "portfolio/fancythat"
etc...
谢谢!
答案 0 :(得分:1)
resources :portfolio do
collection do
get 'occupy'
get 'armstrong'
...
end
end
静态页面在Rails中有点尴尬。你应该尽量减少它们。 Here's a RailsCast处理一些不同的解决方案。