Apache => wrong rest routing

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?

On 8/11/07, Maarten P. [email protected] 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


Rick O.
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com

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?

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.