2010-10-11 57 views
0

我正在構建一個應用來管理一些產品,所以我有一個產品模型。關於Rails 3的建議 - 路由 - Restfull

我們出售,購買,當產品發生故障時,我們會將其發送給製造商進行維修。

因此,我創建了一個Movimentation模型,它將處理產品的所有細節。

當我們購買產品時,會爲Movimentation表上的每個產品生成一個In記錄。出售和修理。

我試圖讓它更可靠,這就是爲什麼我很困惑。

我應該怎麼做?資源:移動?或者我應該創建一個「product_in」和一個「product_out」控制器?

我想要urls像「movimentation /:to_where /:方向」(進/出),因此正確繪製視圖。

有沒有粘性?

回答

0

你可以有一個movimentation_controller進/出動作和:to_where參數。所以對於路線有兩種選擇:

#if you have other REST actions do this: 
resources :movimentation do 
    member do 
    get :in 
    get :out 
    end 
end 

#or go with a match: 
match '/movimentation/in/:to_where' => 'movimentation#in' 
match '/movimentation/out/:to_where' => 'movimentation#out' 

歡呼聲, A.