views:

32

answers:

1

I'm building a app to manage some products, so I have a Product model.

We sell, buy and when a product breakes, we send it to the manufacturer for repair.

So, I've created a Movimentation model, that will take care of all ins and outs of a product.

When we bought a product, a In record is generated for each product on the Movimentation table. Out for sells and repairs.

I'm trying to make it the more restfull possible, and that's why I'm confused.

How should I do it? A resource :movimentation ? Or should I create a "product_in" and a "product_out" controllers?

I want urls to be like "movimentation/:to_where/:direction" (in/out) and so draw the views correctly.

Any toughts?

A: 

you could have a movimentation_controller with in/out actions and :to_where param. so for the routes you have two choices:

#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'

cheers, A.

apeacox