0

「about」を「abouts/1」にルーティングしたい

私はこれを試しました:

match 'about' => 'abouts#show/1', :via => get

そしてそれはうまくいきません。何か案は?

4

2 に答える 2

3

What about just removing the 1 from the route and retrieve the record you want directly in the controller method?

# routes.rb
match 'about' => 'abouts#show', :via => get

# abouts_controller.rb
def show
  @about = About.find(1)
end
于 2012-06-16T22:52:55.283 に答える
3

どうですか:

match 'about' => 'abouts#show', :via => :get, :defaults => {:id => 1}
于 2012-06-16T22:57:15.533 に答える