Back

I was watching a talk recently about testing your code (it might have been @nunomaduro 's talk on Pest 3?) that mentioned that your controllers should ONLY have the resource / CRUD methods in them.

I'm building a more complex app that has routes related to a user taking a test that's doing a lot more than just those methods. If not in a controller, where should those methods be placed?

I have a TestSessionController that handles all of the routes for the next question and grading the test and the questions. I am moving a lot of the functionality out of the controller and into Action classes, but I still use different methods in my controller to call those actions.

Or was that just an example of what could be done, and not necessarily a "best practice" sort of thing? Any help would be great!

3

245

In response to @FinalAsgard

Personally, I have mixed feelings about this principle. I don’t like all facets of ‘Cruddy by Design’ or what it does to your code. I usually stick to resourceful controllers, and anything that doesn’t belong there gets its own invokable controller with a clear, descriptive name.

116

  • No matching results...
  • Searching...

/ 1000