non-RESTful actions in Rails
<p>OK, while GitHub is down, a code design question:<br>
I always get analysis paralysis with non-standard RESTful actions in rails apps (and generally).</p>

<p>I've got Jobs, and I want to be able to cancel (and re-activate) them. It's not as simple as setting a checkbox; there's a few other things that need to happen., so I can't just use the existing <code>JobsController#update</code> action.</p>

<p>Here are my options as I see it:</p>

<p><strong>1.</strong> Just add <code>cancel</code> and <code>reactivate</code> to existing jobs controller.
The routes would be something like:</p>

<pre><code>POST /admin/jobs/cancel/:job_id
POST /admin/jobs/reactivate/:job_id
</code></pre>

<p><em>(Not RESTful; assuming this is a bad idea)</em></p>

<p><strong>2.</strong> Create a <code>JobCancellationsController</code> with <code>create</code> and <code>destroy</code> actions.
Re-activating a job is <code>destroy</code>-ing a <code>JobCancellation</code> resource.</p>

<p>I'll use nested routes as per below:</p>

<pre><code>resources :jobs, except: :show do
  resource :job_cancellation, only: [:create, :destroy]
end
</code></pre>

<p>which by default will give me something like</p>

<p>a)</p>

<pre><code>POST /admin/jobs/:job_id/job_cancellation
DELETE /admin/jobs/:job_id/job_cancellation
</code></pre>

<p>I could tidy the routes themselves up, without changing the controller, to be like:</p>

<p>b) </p>

<pre><code>POST /admin/jobs/:job_id/cancellation
DELETE /admin/jobs/:job_id/cancellation
</code></pre>

<p>Although that doesn't seem very intuitive - 'cancellation' would be better as <code>cancel</code>. So I can change the routes while keeping the controller the same:</p>

<p>c)</p>

<pre><code>POST /admin/jobs/:job_id/cancel
DELETE /admin/jobs/:job_id/cancel
</code></pre>

<p>That first route now makes sense (although it's not <code>RESTful</code> strictly speaking?), but the second doesn't... "deleting a job cancel"? So you'd change it to something like: </p>

<p>d)</p>

<pre><code>POST /admin/jobs/:job_id/cancel
POST /admin/jobs/:job_id/reactivate
</code></pre>

<p>Now the routes makes sense, but look suspiciously close to option 1) above, even though the routes do map to RESTful actions in the <code>JobCancellationsController</code> rather than non-RESTful actions in the <code>JobsController</code>. And it seems very bizzare to have the <code>POST /admin/jobs/:job_id/reactivate</code> route mapping to the <code>JobCancellationsController#destroy</code> action.</p>

<p>To avoid that last odity with <code>JobCancellationsController#destroy</code>, I could instead do:</p>

<p><strong>3.</strong> Similar to option 2, but create two controllers: <code>JobCancellationsController</code> with a <code>create</code> action only, and <code>JobReactivationsController</code> with a <code>create</code> action only.</p>

<p>What's the 'correct' way to do this? Or at least, which are the 'incorrect' ways that I can quickly eliminate? Is there a totally different, better way that I've missed?</p>