2

非常に基本的な質問があります。次のような Rails コードを見ていますが、解釈できません。これから推測される REST URL と対応するアクションは何ですか? 同様のルートの例が見つからなかったので、誰かが理解を助けてくれませんか。

map.resources :myresources do |item|
    item.resources :v, :controller => 'my_controller' do |v|
      v.resource :abc
    end
end

前もって感謝します!!

4

1 に答える 1

0

これは実際には古いルーティング スタイルです。これで、次のようにコードを記述できます。

resources :myresources do
  resources :v, :controller => "my_controller" do
    resource :abc
  end
end

このコードを使用すると、次のルートを取得できます。

     myresource_v_abc POST   /myresources/:myresource_id/v/:v_id/abc(.:format)      abcs#create
 new_myresource_v_abc GET    /myresources/:myresource_id/v/:v_id/abc/new(.:format)  abcs#new
edit_myresource_v_abc GET    /myresources/:myresource_id/v/:v_id/abc/edit(.:format) abcs#edit
                      GET    /myresources/:myresource_id/v/:v_id/abc(.:format)      abcs#show
                      PUT    /myresources/:myresource_id/v/:v_id/abc(.:format)      abcs#update
                      DELETE /myresources/:myresource_id/v/:v_id/abc(.:format)      abcs#destroy
   myresource_v_index GET    /myresources/:myresource_id/v(.:format)                my_controller#index
                      POST   /myresources/:myresource_id/v(.:format)                my_controller#create
     new_myresource_v GET    /myresources/:myresource_id/v/new(.:format)            my_controller#new
    edit_myresource_v GET    /myresources/:myresource_id/v/:id/edit(.:format)       my_controller#edit
         myresource_v GET    /myresources/:myresource_id/v/:id(.:format)            my_controller#show
                      PUT    /myresources/:myresource_id/v/:id(.:format)            my_controller#update
                      DELETE /myresources/:myresource_id/v/:id(.:format)            my_controller#destroy
          myresources GET    /myresources(.:format)                                 myresources#index
                      POST   /myresources(.:format)                                 myresources#create
       new_myresource GET    /myresources/new(.:format)                             myresources#new
      edit_myresource GET    /myresources/:id/edit(.:format)                        myresources#edit
           myresource GET    /myresources/:id(.:format)                             myresources#show
                      PUT    /myresources/:id(.:format)                             myresources#update
                      DELETE /myresources/:id(.:format)                             myresources#destroy
于 2012-11-12T13:49:39.563 に答える