# non-CRUD actions with REST

**URL:** <https://www.ruby-forum.com/t/non-crud-actions-with-rest/145113>\
**Category:** Rails\
**Created:** [August 6, 2008, 5:37am UTC](https://www.ruby-forum.com/t/non-crud-actions-with-rest/145113 "2008-08-06T05:37:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mostafa\_badawi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f14d63/32.png) [@mostafa\_badawi](https://www.ruby-forum.com/u/mostafa_badawi)\
**Post date:** [August 6, 2008, 5:37am UTC](https://www.ruby-forum.com/t/non-crud-actions-with-rest/145113/1 "2008-08-06T05:37:57Z")

</div>

Hi all,

About non-CRUD actions, how they are handled with RESTful application.  
I mean that if i needed to use _link\_to_ to that kind of actions, how  
it’s  
done.

thanks,  
Sorry for disturbance,  
Mostafa Badawi

---

<div class="post-metadata">

**Author:** ![mostafa\_badawi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f14d63/32.png) [@mostafa\_badawi](https://www.ruby-forum.com/u/mostafa_badawi)\
**Post date:** [August 6, 2008, 6:52am UTC](https://www.ruby-forum.com/t/non-crud-actions-with-rest/145113/2 "2008-08-06T06:52:12Z")

</div>

> **[frozenplague.net](http://frozenplague.net/2008/01/06/restful-routing-an-overview/)**
>
> This domain may be for sale!

This answers most questions about routing and I don’t know why more  
people don’t link to it!

---

<div class="post-metadata">

**Author:** ![mostafa\_badawi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f14d63/32.png) [@mostafa\_badawi](https://www.ruby-forum.com/u/mostafa_badawi)\
**Post date:** [August 6, 2008, 6:51am UTC](https://www.ruby-forum.com/t/non-crud-actions-with-rest/145113/3 "2008-08-06T06:51:02Z")

</div>

Greetings Mostafa,

If you are creating custom actions, there are many ways to route to  
them. One of those ways is named routes. If you take a look in the  
config/routes.rb file, you should find a lot of example routes you can  
setup. Everything is processed from top to bottom. Thus, your should  
have your most specific routes near the top and your most general  
routes near the bottom.

Here is an example:

map.purchase ‘products/:id/purchase’, :controller =\>  
‘catalog’, :action =\> ‘purchase’  
[www.example.com/products/3/purchase](http://www.example.com/products/3/purchase) would be routed to the catalog  
controller, using the purchase action

To understand what routes are available to you, run the rake command:  
rake routes. Reading this list, take the name of the route and add  
either a \_path, or \_url, and the correct path or URL will be created.  
You can experiment with this by printing your path / URL to the screen  
in an erb file. For example:

\<%= example\_route\_path %\> would output something like /example/

Hope that helps some. Search the group for REST and I’m sure you’ll  
come up with loads of helpful information. :o)

~Dustin T.

---

<div class="post-metadata">

**Author:** ![mostafa\_badawi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/f14d63/32.png) [@mostafa\_badawi](https://www.ruby-forum.com/u/mostafa_badawi)\
**Post date:** [August 6, 2008, 6:58am UTC](https://www.ruby-forum.com/t/non-crud-actions-with-rest/145113/4 "2008-08-06T06:58:03Z")

</div>

Next time… I’ll link. :o) Very helpful article, and funny too!  
That’s a lot better than my short explanation.

~Dustin T.
