# Renaming RESTful actions

**URL:** <https://www.ruby-forum.com/t/renaming-restful-actions/89053>\
**Category:** Rails\
**Created:** [March 16, 2007, 7:34pm UTC](https://www.ruby-forum.com/t/renaming-restful-actions/89053 "2007-03-16T19:34:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jruyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jruyle](https://www.ruby-forum.com/u/jruyle)\
**Post date:** [March 16, 2007, 7:34pm UTC](https://www.ruby-forum.com/t/renaming-restful-actions/89053/1 "2007-03-16T19:34:11Z")

</div>

I’ve got a RESTful controller that takes in a file upload as the main  
input  
into a table. I want to rename POST:resources\_url to hit #upload instead  
of  
#create. Is there something I can specify on map.resources that allows  
me to  
do this? Or am I stuck generating a URL like “/resource/;upload” ?

Jason

---

<div class="post-metadata">

**Author:** ![jruyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jruyle](https://www.ruby-forum.com/u/jruyle)\
**Post date:** [March 16, 2007, 7:38pm UTC](https://www.ruby-forum.com/t/renaming-restful-actions/89053/2 "2007-03-16T19:38:11Z")

</div>

On 3/16/07, Jason R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’ve got a RESTful controller that takes in a file upload as the main  
> input into a table. I want to rename POST:resources\_url to hit #upload  
> instead of #create. Is there something I can specify on map.resources that  
> allows me to do this? Or am I stuck generating a URL like  
> “/resource/;upload” ?
> 
> Jason

A little more information, here’s my test (which is failing, difference  
being :action =\> ‘create’ is generated, not ‘upload’):

```
assert_recognizes({:controller => 'taxes', :action => 'upload'}, 

```

{:path  
=\> ‘taxes’, :method =\> :post})

and current routing

map.resources :taxes, :new =\> {:upload =\> :post}

Jason

---

<div class="post-metadata">

**Author:** ![jruyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jruyle](https://www.ruby-forum.com/u/jruyle)\
**Post date:** [March 16, 2007, 8:08pm UTC](https://www.ruby-forum.com/t/renaming-restful-actions/89053/3 "2007-03-16T20:08:14Z")

</div>

On 3/16/07, FranÃ§ois Beausoleil [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 
> 
> ## Bye !
> 
> FranÃ§ois Beausoleil  
> [http://blog.teksol.info/](http://blog.teksol.info/)  
> [http://piston.rubyforge.org/](http://piston.rubyforge.org/)

I know that the old routing is still available, I’m trying to stay away  
from  
it as much as I can. The problem I have with REST right now is that  
there is  
no “accepted spec” for doing REST, if that makes any sense. When it  
comes to  
controllers that are a little more complex than just serving up a view  
to a  
model, is it ok to drop out of REST? What is the point that a site is  
no-longer RESTful?

Jason

---

<div class="post-metadata">

**Author:** ![jruyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jruyle](https://www.ruby-forum.com/u/jruyle)\
**Post date:** [March 16, 2007, 8:39pm UTC](https://www.ruby-forum.com/t/renaming-restful-actions/89053/4 "2007-03-16T20:39:19Z")

</div>

2007/3/16, Jason R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I know that the old routing is still available, I’m trying to stay away from  
> it as much as I can. The problem I have with REST right now is that there is  
> no “accepted spec” for doing REST, if that makes any sense. When it comes to  
> controllers that are a little more complex than just serving up a view to a  
> model, is it ok to drop out of REST? What is the point that a site is  
> no-longer RESTful?

You have to be pragmatic. If the REST philosophy doesn’t fit a  
particular case, well, don’t bother.

## Hope that helps !

François Beausoleil  
[http://blog.teksol.info/](http://blog.teksol.info/)  
[http://piston.rubyforge.org/](http://piston.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![jruyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jruyle](https://www.ruby-forum.com/u/jruyle)\
**Post date:** [March 16, 2007, 8:04pm UTC](https://www.ruby-forum.com/t/renaming-restful-actions/89053/5 "2007-03-16T20:04:14Z")

</div>

Hi,

2007/3/16, Jason R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> A little more information, here’s my test (which is failing, difference  
> being :action =\> ‘create’ is generated, not ‘upload’):
> 
> ```
> assert_recognizes({:controller => 'taxes', :action => 'upload'}, {:path
> 
> ```
> 
> =\> ‘taxes’, :method =\> :post})
> 
> and current routing
> 
> map.resources :taxes, :new =\> {:upload =\> :post}

map.connect “/taxes/upload”, :controller =\> “taxes”, :action =\> “upload”

Everything that existed before resources still exists now that  
resources are here. That’s one of the nice thing. We get to make our  
cake and eat it too 🙂

## Bye !

François Beausoleil  
[http://blog.teksol.info/](http://blog.teksol.info/)  
[http://piston.rubyforge.org/](http://piston.rubyforge.org/)

---

<div class="post-metadata">

**Author:** ![jruyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jruyle](https://www.ruby-forum.com/u/jruyle)\
**Post date:** [March 16, 2007, 9:13pm UTC](https://www.ruby-forum.com/t/renaming-restful-actions/89053/6 "2007-03-16T21:13:24Z")

</div>

On 3/16/07, FranÃ§ois Beausoleil [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > model, is it ok to drop out of REST? What is the point that a site is  
> > no-longer RESTful?
> 
> You have to be pragmatic. If the REST philosophy doesn’t fit a  
> particular case, well, don’t bother.
> 
> ## Hope that helps !
> 
> FranÃ§ois Beausoleil  
> [http://blog.teksol.info/](http://blog.teksol.info/)  
> [http://piston.rubyforge.org/](http://piston.rubyforge.org/)

It _does_ fit. All I’m trying to do is rename the action being used by  
the  
POST action (default create, I want to rename it to upload). Is this  
possible?

Jason

---

<div class="post-metadata">

**Author:** ![jruyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jruyle](https://www.ruby-forum.com/u/jruyle)\
**Post date:** [March 18, 2007, 4:15pm UTC](https://www.ruby-forum.com/t/renaming-restful-actions/89053/7 "2007-03-18T16:15:34Z")

</div>

One thing I had to let go of when I started using the RESTful  
methodology  
was the need to have my urls all styled looking with no parameters  
hanging  
out looking all ugly. Sometimes getting those params inline is a matter  
of  
rethinking things and nesting routes but sometimes you just have to  
raise up  
those hands and concede to the RESTy way. I’m still bugged by things  
like  
[http://domain.com/users/1/entries;?page=2](http://domain.com/users/1/entries;?page=2) but I’ve come to accept them  
[on  
my admin side\*] as accurate representations of what is important and  
what is  
ephemeral/peripheral information. In this case, the fact that the data  
on  
page two isn’t necessarily the same every time is a good indicator that  
it’s  
not actually a resource itself and therefore just a hanging param.  
Perhaps  
your desire to rename “create” to “upload” without having to change its  
basic function is similar. 🙂

RSL

\*On my spiderable content side, I’ve heard that urls like  
[http://domain.com/users/1/entries;?page=2](http://domain.com/users/1/entries;?page=2) don’t get indexed and  
therefore  
aren’t perhaps the best way of arranging one’s archives. YMMV

---

<div class="post-metadata">

**Author:** ![jruyle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/d2c977/32.png) [@jruyle](https://www.ruby-forum.com/u/jruyle)\
**Post date:** [March 17, 2007, 1:24am UTC](https://www.ruby-forum.com/t/renaming-restful-actions/89053/8 "2007-03-17T01:24:09Z")

</div>

Hi Jason,

Earlier on you said: Or am I stuck generating a URL like “/  
resource/;upload”

Forgive me if I’m being dense, but _why_ do you want he default POST  
to call a method called update() rather than create()? It seems to  
me that if you want POST /some/url to perform a specific set of  
actions, why wouldn’t you just do those actions in _create_ rather  
than fight the framework?

Or, are you in fact saying that you want to have _two_ urls to create  
a resource in your :taxes resource collection: one that calls create  
() and another that calls upload()?

If so, have you tried:

map.resources :taxes, :collection =\> {:upload =\> :post}

However, that most definitely _does_ generate a resource url like /  
taxes;upload so it may not be what you’re looking for.

Regards,  
Trevor
