开发者

(Rails 3) Is it possible to hardcode ids in a named route?

开发者 https://www.devze.com 2023-02-06 02:36 出处:网络
As far as I know, the following is the encouraged way to create a simple named route in Rails 3: match \'sign-in\' =>开发者_开发技巧 \'sessions#create\', :as => :sign_in

As far as I know, the following is the encouraged way to create a simple named route in Rails 3:

match 'sign-in' =>开发者_开发技巧 'sessions#create', :as => :sign_in

Is there a clean way to hardcode an id (or any parameter) in a named route? For a silly example:

match 'first-user' => 'users#show', :as => :first_user, :id => 1


Did you try that? It just works like that.

0

精彩评论

暂无评论...
验证码 换一张
取 消