Angela
Angela

Reputation: 3110

How to determine which controller an action belongs in?

I have two models: releases have many elements, and elements belong to releases.

The action I wish to define imports all elements (making copies of them all) from one release into another release.

How do I determine if this action belongs as a member action on the releases controller, or a collection action on the elements controller?

Upvotes: 1

Views: 192

Answers (2)

Christopher Hazlett
Christopher Hazlett

Reputation: 326

I would put it into an elements controller. The action you're doing is one against the elements not against the releases. This separates your concerns a little more accurately...I think.

Upvotes: 0

chaos
chaos

Reputation: 124297

I would put it on the releases controller. Now, if I can figure out why I would do that...

The best I can verbalize is that since it's always operating on all the elements of a release, rather than ever operating on individual or ad-hoc subsets of elements, it seems to be a release operation rather than an element operation.

Upvotes: 2

Related Questions