# Confusing routing behavior

**URL:** <https://www.ruby-forum.com/t/confusing-routing-behavior/178523>\
**Category:** Rails\
**Created:** [November 5, 2009, 9:47pm UTC](https://www.ruby-forum.com/t/confusing-routing-behavior/178523 "2009-11-05T21:47:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adammontgomery](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@adammontgomery](https://www.ruby-forum.com/u/adammontgomery)\
**Post date:** [November 5, 2009, 9:47pm UTC](https://www.ruby-forum.com/t/confusing-routing-behavior/178523/1 "2009-11-05T21:47:12Z")

</div>

Hi everyone

I have a strange routing behavior. And I don’t know when it started  
being.  
I have a form for image upload using attachment\_fu. The code in the view  
is

\<% form\_for(:image, :url =\> “/images/create”, :html =\> { :multipart =\>  
true }) do |form| %\>

\<%= form.file\_field :uploaded\_data, :size =\> 15, :class =\> “formLoader”  
%\>

\<% end %\>

and the controller code is

def create  
# Used by start/index  
@image = Image.new(params[:image])  
@image.kwiker\_id = session[:kwiker]  
if @image.save  
redirect\_to(‘/grusskarten/deinenachricht/’ + @image.id.to\_s)  
else  
flash[:error] = ‘Das Bild konnte nicht hochgeladen werden.’  
redirect\_to(:controller =\> ‘start’)  
end  
end

so it should route me to /grusskarten/deinenachricht/  
if succesful. But I run into a 404 error. The prod.log says

Processing ImagesController#create (for 95.116.6.201 at 2009-11-05  
21:38:20) [POST]  
Session ID: 33d68daef3fd8a51b3ec968b916ace06  
Parameters: {“x”=\>“70”, “y”=\>“23”, “action”=\>“create”,  
“authenticity\_token”=\>“020d41a157fbc69c314d369d73f7dd47b9fe070f”,  
“controller”=\>“images”, “image”=\>{“uploaded\_data”=\>#\<File:/tmp/CGI5622  
Redirected to [https://test.kwikit.de/images/create](https://test.kwikit.de/images/create)  
Filter chain halted as [:ensure\_proper\_protocol] rendered\_or\_redirected.  
Completed in 0ms (DB: 2) | 302 Found  
[[http://test.kwikit.de/images/create](http://test.kwikit.de/images/create)]

Processing ImagesController#show (for 95.116.6.201 at 2009-11-05  
21:38:20) [GET]  
Session ID: 33d68daef3fd8a51b3ec968b916ace06  
Parameters: {“action”=\>“show”, “id”=\>“create”, “controller”=\>“images”}

ActiveRecord::RecordNotFound (Couldn’t find Image with ID=create):  
/usr/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active\_record/base.rb:

Why does he routes me to ImagesController and action =\> show???  
It happens only on my production server.

---

<div class="post-metadata">

**Author:** ![adammontgomery](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@adammontgomery](https://www.ruby-forum.com/u/adammontgomery)\
**Post date:** [November 5, 2009, 9:54pm UTC](https://www.ruby-forum.com/t/confusing-routing-behavior/178523/2 "2009-11-05T21:54:20Z")

</div>

What happens in dev mode locally

Processing ImagesController#create (for 127.0.0.1 at 2009-11-05  
21:52:27) [POST]  
Session ID: 2e54b69d91dafe551b5edabc637c019b  
Parameters: {“x”=\>“52”, “y”=\>“21”, “action”=\>“create”,  
“authenticity\_token”=\>“4221d581c4a9acc11ef32170b788078b70b3e282”,  
“controller”=\>“images”,  
“image”=\>{“uploaded\_data”=\>#\<File:/var/folders/5c/5cG2ScrbEriNyQAAX0GkLU+++TI/-Tmp-/CGI1416-1\>}}  
e[4;36;1mImage Create (11.8ms)e[0m e[0;1mINSERT INTO “images”  
(“name”, “size”, “created\_at”, “content\_type”, “kwiker\_id”, “thumbnail”,  
“category\_id”, “filename”, “height”, “parent\_id”, “width”, “fake\_sold”,  
“real\_sold”) VALUES(NULL, 336787, ‘2009-11-05 21:52:30’, ‘image/png’,  
4100684228, NULL, NULL, ‘c8e367cf60f5f85cd598a9c5c364def122066836.png’,  
565, NULL, 755, NULL, NULL)e[0m  
e[4;35;1mImage Load (0.7ms)e[0m e[0mSELECT \* FROM “images” WHERE  
(“images”.“thumbnail” = ‘thumb’ AND “images”.“parent\_id” = 67) LIMIT  
1e[0m  
e[4;36;1mImage Create (0.7ms)e[0m e[0;1mINSERT INTO “images”  
(“name”, “size”, “created\_at”, “content\_type”, “kwiker\_id”, “thumbnail”,  
“category\_id”, “filename”, “height”, “parent\_id”, “width”, “fake\_sold”,  
“real\_sold”) VALUES(NULL, 309301, ‘2009-11-05 21:52:30’, ‘image/png’,  
NULL, ‘thumb’, NULL,  
‘c8e367cf60f5f85cd598a9c5c364def122066836\_thumb.png’, 112, 67, 150,  
NULL, NULL)e[0m  
Redirected to /grusskarten/deinenachricht/67  
Completed in 3076ms (DB: 14) | 302 Found  
[[http://localhost/images/create](http://localhost/images/create)]

Processing GrusskartenController#deinenachricht (for 127.0.0.1 at  
2009-11-05 21:52:31) [GET]  
Session ID: 2e54b69d91dafe551b5edabc637c019b  
Parameters: {“action”=\>“deinenachricht”, “id”=\>“67”,  
“controller”=\>“grusskarten”}  
e[4;35;1mOrder Load (0.2ms)e[0m e[0mSELECT \* FROM “orders” WHERE  
(kwiker\_id= 4100684228 AND status = 0) LIMIT

As it should be…

---

<div class="post-metadata">

**Author:** ![adammontgomery](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@adammontgomery](https://www.ruby-forum.com/u/adammontgomery)\
**Post date:** [November 5, 2009, 10:50pm UTC](https://www.ruby-forum.com/t/confusing-routing-behavior/178523/3 "2009-11-05T22:50:26Z")

</div>

I have it! It was because of

# protected

# def ssl\_required?

# ENV[“RAILS\_ENV”] == “production”

# end

in the image controller. But why?
