# Question regarding controller actions (And a little bit of REST)

**URL:** <https://www.ruby-forum.com/t/question-regarding-controller-actions-and-a-little-bit-of-rest/191745>\
**Category:** Rails\
**Created:** [July 17, 2010, 12:31pm UTC](https://www.ruby-forum.com/t/question-regarding-controller-actions-and-a-little-bit-of-rest/191745 "2010-07-17T12:31:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mffreire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/90ced4/32.png) [@mffreire](https://www.ruby-forum.com/u/mffreire)\
**Post date:** [July 17, 2010, 12:31pm UTC](https://www.ruby-forum.com/t/question-regarding-controller-actions-and-a-little-bit-of-rest/191745/1 "2010-07-17T12:31:48Z")

</div>

Hi Guys,

I am developing a blog system with Rails and I have a question about the  
following matter:

My client wants me to create an _approve_ and _disapprove_ action for  
the  
comments.

So, I did create two actions in the rails comment controller called by a  
\*  
put\* method, since the only thing they do is change the _approved_  
collumn  
at the database. I am still not familiar with REST, so I decided to ask  
what  
you would do in a situation like this.

Another way I was thinking is create an action update and there I would  
handle if I get a params[:approve] or a params[:disapprove]. I know it  
is a  
quite simple question, but I did research, but I think I didn’t find the  
right keywords to look for it.

Thanks for any inputs in advance.  
Marco Antonio

---

<div class="post-metadata">

**Author:** ![mffreire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/90ced4/32.png) [@mffreire](https://www.ruby-forum.com/u/mffreire)\
**Post date:** [July 17, 2010, 1:59pm UTC](https://www.ruby-forum.com/t/question-regarding-controller-actions-and-a-little-bit-of-rest/191745/2 "2010-07-17T13:59:00Z")

</div>

I would try to use 2 radio buttons, or a select box with values:

- Approved
- Not approved
- … other states

Then, you embed the processing of these values in the UPDATE action.  
For a select box, this might help you to start:

- \<%= select(:blogpost, "status\_id", Status.all.collect {|p| [p.name, p.id] }) %\>

hph,

patrick

---

<div class="post-metadata">

**Author:** ![mffreire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/90ced4/32.png) [@mffreire](https://www.ruby-forum.com/u/mffreire)\
**Post date:** [July 21, 2010, 9:05am UTC](https://www.ruby-forum.com/t/question-regarding-controller-actions-and-a-little-bit-of-rest/191745/3 "2010-07-21T09:05:21Z")

</div>

Thank you guys.

Bill, you helped me a lot. That was exactly what I needed to hear.

Well, I came here once again just to share this article that I found  
that  
answers my questions too. In case someone have the same question.

[http://dathompson.blogspot.com/2008/07/restful-rails-passing-url-parameters.html](http://dathompson.blogspot.com/2008/07/restful-rails-passing-url-parameters.html)

[http://dathompson.blogspot.com/2008/07/restful-rails-passing-url-parameters.html](http://dathompson.blogspot.com/2008/07/restful-rails-passing-url-parameters.html)  
Regards,  
Marco Antonio

---

<div class="post-metadata">

**Author:** ![mffreire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/90ced4/32.png) [@mffreire](https://www.ruby-forum.com/u/mffreire)\
**Post date:** [July 17, 2010, 2:16pm UTC](https://www.ruby-forum.com/t/question-regarding-controller-actions-and-a-little-bit-of-rest/191745/4 "2010-07-17T14:16:34Z")

</div>

Hi Marco,

On Sat, Jul 17, 2010 at 5:29 AM, Marco Antonio F.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> handle if I get a params[:approve] or a params[:disapprove].  
> I think, in the end, you’re making a choice is between:

/blog/23/comments/4/approve

and

/blog/23/comments/4?approve

From a REST perspective, the latter is probably slightly more  
preferred. Fielding’s dissertation does not provide a prescription at  
this level of detail, focusing instead on the need for unique resource  
identifiers. In the sense that the resource itself is more clearly  
identified in your proposal, I would venture an opinion that it is  
more RESTful than your client’s proposal. But I wouldn’t get wrapped  
around the axle with a client on that point.

From a code maintenance perspective,however, the latter is much more  
preferable in that it requires only one method (update) instead of two  
(approve/disapprove). Additionally, the Rails routing engine  
supports / generates the CRUD methods by default, whereas you will  
need to do extra work to support your client’s request. That reduced  
complexity translates to $$$ which, in my experience, typically  
engages clients instantly.

HTH,  
Bill
