# Problems with form\_for(@message.attachments.build ...)

**URL:** <https://www.ruby-forum.com/t/problems-with-form-for-message-attachments-build/164274>\
**Category:** Rails\
**Created:** [March 30, 2009, 8:43pm UTC](https://www.ruby-forum.com/t/problems-with-form-for-message-attachments-build/164274 "2009-03-30T20:43:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [March 30, 2009, 8:43pm UTC](https://www.ruby-forum.com/t/problems-with-form-for-message-attachments-build/164274/1 "2009-03-30T20:43:40Z")

</div>

Hi, I’m puzzled by the next.

I have messages that have attachments.  
I have an index action for the attachments where I list all the  
attachments that a message has. From the same index page I can also add  
new attachments to that message.

For that I’ve been using the next form

\<% form\_for(@message.attachments.build, :html =\> { :multipart =\> true })  
do |f| %\>  
\<%= hidden\_field\_tag ‘mess’, @message.id %\>

Attachment: \<%= f.file\_field :uploaded\_data, :size =\> "20" %\>

 \<%= submit\_tag('Attach', { :class =\> "bigButton" }) %\> \<% end %\>

In my local environment (upgraded now to Rails 2.3.2, I originally did  
this in Rails 2.1.2) that sends a request to the Create method of the  
attachments controller as expected.

However in the real server (Rails 2.1.2) the same sends a request to the  
Index method of the attachments controller.

Anyone sees a reason why it goes to the Index method in the real server?  
Maybe something is different in those versions (?)

Thanks.

---

<div class="post-metadata">

**Author:** ![comopasta](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/59ef9b/32.png) [@comopasta](https://www.ruby-forum.com/u/comopasta)\
**Post date:** [March 30, 2009, 11:28pm UTC](https://www.ruby-forum.com/t/problems-with-form-for-message-attachments-build/164274/2 "2009-03-30T23:28:23Z")

</div>

Hi,

Fixed thanks to a suggestion from:  
[http://railsforum.com/viewtopic.php?id=28784](http://railsforum.com/viewtopic.php?id=28784)

Cheers.
