0

我很难理解 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

ETC...

路线如下所示:

NewPortfolio::Application.routes.draw do

get "portfolio/uniquename1"
get "portfolio/rexpage"
get "portfolio/armstrong" 
get "portfolio/occupy" 
get "portfolio/fancythat" 

etc...

谢谢!

4

1 回答 1

1
resources :portfolio do
  collection do
    get 'occupy'
    get 'armstrong'
    ...
  end
end

静态页面在 Rails 中有点尴尬。你应该尽量减少它们。这是一个处理几种不同解决方案的 RailsCast 。

于 2012-07-02T19:17:37.887 回答