apache => wrong rest routing

2 views
Skip to first unread message

Maarten Porters

unread,
Aug 11, 2007, 3:48:13 PM8/11/07
to rubyonra...@googlegroups.com
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?
--
Posted via http://www.ruby-forum.com/.

Rick Olson

unread,
Aug 11, 2007, 5:15:20 PM8/11/07
to rubyonra...@googlegroups.com

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 Olson
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com

Maarten Porters

unread,
Aug 12, 2007, 5:14:32 AM8/12/07
to rubyonra...@googlegroups.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?

Maarten Porters

unread,
Aug 12, 2007, 6:23:11 AM8/12/07
to rubyonra...@googlegroups.com
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.

Reply all
Reply to author
Forward
0 new messages