Forum: Ruby on Rails Problems with form_for(@message.attachments.build ...)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
comopasta G. (Guest)
on 2009-03-30 22:43
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 %>
  <p>Attachment: <%= f.file_field :uploaded_data, :size => "20" %></p>
  <%= 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.
comopasta G. (Guest)
on 2009-03-31 01:28
Hi,

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

Cheers.
This topic is locked and can not be replied to.