# Apache =\> wrong rest routing

**URL:** <https://www.ruby-forum.com/t/apache-wrong-rest-routing/111832>\
**Category:** Rails\
**Created:** [August 11, 2007, 9:48pm UTC](https://www.ruby-forum.com/t/apache-wrong-rest-routing/111832 "2007-08-11T21:48:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![temesta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@temesta](https://www.ruby-forum.com/u/temesta)\
**Post date:** [August 11, 2007, 9:48pm UTC](https://www.ruby-forum.com/t/apache-wrong-rest-routing/111832/1 "2007-08-11T21:48:13Z")

</div>

Hello,

I’m having a strange routing problem. When I try to post my form, apache  
rederects me to the wrong action (index).

This is my form tag:

\<% form\_tag(assets\_url,:multipart =\> true  
,:id=\>“fileform”,:method=\>:post) do %\>

On my local machine (webbrick) , it redirects me correctly to the create  
action in my assets controller. When I post this form on my apache  
server, I’m redirected to the index action. So I ended up with creating  
this tag:

\<% form\_tag(createnew\_assets\_url,:multipart =\> true  
,:id=\>“fileform”,:method=\>:post) do %\>

I added a createnew method in my assets controller + I fixed the new  
route.

This is a very bad solution but I don’t understand why apache is  
redirecting me to the wrong url. Any suggestions?

---

<div class="post-metadata">

**Author:** ![temesta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@temesta](https://www.ruby-forum.com/u/temesta)\
**Post date:** [August 11, 2007, 11:16pm UTC](https://www.ruby-forum.com/t/apache-wrong-rest-routing/111832/2 "2007-08-11T23:16:38Z")

</div>

On 8/11/07, Maarten P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> This is a very bad solution but I don’t understand why apache is  
> redirecting me to the wrong url. Any suggestions?

Are you using page caching? Perhaps it sees that you have  
/foo/index.html so redirects POST /foo to GET /foo/.

Try this:

[http://mephisto.stikipad.com/help/show/Developer+Tips](http://mephisto.stikipad.com/help/show/Developer+Tips)

–  
Rick O.  
[http://lighthouseapp.com](http://lighthouseapp.com)  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![temesta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@temesta](https://www.ruby-forum.com/u/temesta)\
**Post date:** [August 12, 2007, 11:14am UTC](https://www.ruby-forum.com/t/apache-wrong-rest-routing/111832/3 "2007-08-12T11:14:32Z")

</div>

> Are you using page caching? Perhaps it sees that you have  
> /foo/index.html so redirects POST /foo to GET /foo/.

Hi Rick,

I’m not using page caching at all. My form is just doing a GET request  
for assets\_path, instead of a POST. Could this be a rails bug?

---

<div class="post-metadata">

**Author:** ![temesta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e9bcb4/32.png) [@temesta](https://www.ruby-forum.com/u/temesta)\
**Post date:** [August 12, 2007, 12:23pm UTC](https://www.ruby-forum.com/t/apache-wrong-rest-routing/111832/4 "2007-08-12T12:23:11Z")

</div>

I found out the cause of this routing problem. Actually it is related to  
Rick’s attachment\_fu plugin. I’m using the model “asset” which uses the  
plugin. By default, all assets are saved in public/assets . This causes  
some routing conflicts with the controller routes. I fixed it by  
changing the location of uploaded files. So my asset model looks like  
this:

class Asset \< ActiveRecord::Base  
has\_attachment :content\_type =\> :image,  
:storage =\> :file\_system,  
:path\_prefix =\> ‘public/uploads’,  
:max\_size =\> 1.megabytes,  
:resize\_to =\> ‘640x\>’,  
:thumbnails =\> { :thumb =\> ‘80x\>’, :medium =\>  
‘125x\>’,:large=\> ‘190x’ },:processor =\> :Rmagick

Maby you should mention this in the readme of attachment\_fu. It took me  
a while to find the solution.
