rails - REST or create another method

Posted by user1304740 on Stack Overflow See other posts from Stack Overflow or by user1304740
Published on 2012-09-05T03:35:15Z Indexed on 2012/09/05 3:38 UTC
Read the original article Hit count: 113

Filed under:
|

Let's assume we have two models linked with a 1-to-many relationship (like clients and invoices - a client can have many invoices).

In a view of a 'client' (let's say the 'show' view), there is a form to capture an 'invoice'. I found 2 approaches:

  1. This form should be handled by the 'invoice' controller (method create), having client_id passed as a parameter
  2. This form should be handled by a new method in 'client' controller, probably a PUT method defined in routes.rb.

Is there a 'Rails way', or both of them are good? Is there a preffered way?

Thanks!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about rest