0

I found this but it didn't answer my question. Say I have a Payment model, and PaymentConroller. I have the ability to create one payment, edit it, update etc... I also have a method payment_wizard. This method spreads payment according to parameters given in 'payment_wizard' form. But, I want a clean form when I spread new payments, to be able to update an existing collection of payments, and destroy all of them at once. This is making me think that the "right" thing to do would be to create a new controller PaymentWizardController which does all that.

Is this the right way to do this?

Community
  • 1
  • 1
vegansound
  • 23
  • 3
  • You could probably argue the case either way. It's hard to say without knowing more about your app, schema etc. Generally, you would have one controller per database table. Does the wizard stuff have it's own table in the database? – Max Williams Dec 03 '15 at 10:39
  • It doesn't. I just need it to manage a collection of payments. (to create a new collection, destroy a collection etc... ) – vegansound Dec 05 '15 at 17:58

2 Answers2

1

The best approach in my opinion is to keep all your controllers RESTful. Managing a collection of payments could be done by creating a PaymentCollectionController (or however you call it) with update and destroy actions.

Just as is mentined in the question you linked, you don't need a model for every controller you have. Keeping them RESTful is following a convention which makes your code more readable for other users.

Piotr Kruczek
  • 2,384
  • 11
  • 18
0

Think about controller as a handler of actions which are available for user to visit on your site. Do you really need this payment_wizard controller? Try to create some functions in service for PaymenController to keep it slim.

PatNowak
  • 5,721
  • 1
  • 25
  • 31