Hi,
I'm very new to ROR and have aquestion about which stregy to use for
using controllers.
Lets say i have 3 classes:
order
order_lines
customer
I would like to build an application where i can create customer.
create orders (which has belongs to an customer) and add orderlines
(which belongs to an order)
Should i create one controller for each model (eg. order_controller,
customer_controller......) or should I just crceate one
ordermanagement controller that handles them all.
Please provide me with some pros and cons between the two options and
which one you prefer, and way.
//John
I would do an AJAX based cart for this. In this case, since you're not
sending complete new page refreshes, but just updating parts of an
existing page, you'd probably have a controller for orders, where you
can expand / hide / delete / whatever for each order_line. So, you
would have a single controller for both order and order_line (not
order_line_s_ class).
If, however, you don't use any AJAX, and each click causes a different
page to appear, and you want each order_line to appear in its own
page, you'd probably like to use REST for keeping your calls standard.
Then, you'll have an orders_controller and under it (in the REST path
hierarchy) you'd have an order_lines controller.
Customers, being quite independent of the orders would probably get
their own controller.
Amir