Hi, there:
I wanna use plug-in "file_column" to upload image to the server. In
my test app, the view is as follow & it works well:
===================<h1>New entry</h1>
<%= error_messages_for ''entry'' %>
<% form_tag ''create'', :multipart => true do -%>
<p><label for="entry_image">Image</label><br/>
<%= file_column_field ''entry'', ''image''
%></p>
<%= submit_tag ''create'' %>
<% end -%>
<%= link_to ''Back'', entries_path %>
====================
However, in my real app, I scaffold and nest the resource to
RESTful, the view is as follow & it errors: "Do not know how to handle
a string with value ''readme.jpg'' that was passed to a
file_column.
Check if the form''s encoding has been set to
''multipart/form-data''"
=====================<% form_for([@task, @comment]) do |f| %>
<p>
<b>Comment body</b><br />
<%= f.text_area :desc %>
</p>
<p><label
for="comment_image">Image</label><br/>
<%= file_column_field ''comment'',
''image'' %></p>
<p>
<%= f.submit button_name %>
</p>
<% end %>
=====================
I checked the API doc, but seems like "form_for" does not support
option ":multipart => true", what should I do here? Anyone could
explain me what''s differ between "form_for" &
"form_tag" ??
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 14 Jan 2008, at 15:32, myst_tt wrote:> > I checked the API doc, but seems like "form_for" does not support > option ":multipart => true", what should I do here? Anyone could > explain me what''s differ between "form_for" & "form_tag" ??It does, just pass it as the html options, ie form_for :person, @person, :html => {:multipart => true} The api docs on form_for are a good starting point from the difference with form_tag. Fred --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks, Frederick! On Jan 14, 5:36 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 14 Jan 2008, at 15:32, myst_tt wrote: > > > > > I checked the API doc, but seems like "form_for" does not support > > option ":multipart => true", what should I do here? Anyone could > > explain me what''s differ between "form_for" & "form_tag" ?? > > It does, just pass it as the html options, ie > form_for :person, @person, :html => {:multipart => true} > > The api docs on form_for are a good starting point from the difference > with form_tag. > > Fred--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
myst_tt wrote:> <h1>New entry</h1> > <%= error_messages_for ''entry'' %> > <% form_tag ''create'', :multipart => true do -%> > <p><label for="entry_image">Image</label><br/> > <%= file_column_field ''entry'', ''image'' %></p> > <%= submit_tag ''create'' %> > <% end -%> > <%= link_to ''Back'', entries_path %> > ====================>Ran into this issue just now when moving from old rails version to 2.0.2. If you want to use form_tag instead of form_for, you must group your action and controller hash with brackets like this: form_tag( {:action => ''create''}, :multipart => true ) do Otherwise if you indicate :action with no brackets, it then thinks that all of your parameters belong in the same hash with :action, :controller, :params, etc. and puts everything you specify right into the querystring. I think the above would also work without parentheses. - sappworks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-May-10 00:41 UTC
Re: Only "form_tag" support uploading file?
Ben,
I don''t mean to be a ''turd'' here, but that
won''t work. Here is what it
should look like:
<%= form_tag(:url => {:action=> "create" }, :html => {
:multipart =>
true }) -%>
Kathleen
On May 6, 8:15 pm, Ben Sapp
<rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:> myst_tt wrote:
> > <h1>New entry</h1>
> > <%= error_messages_for ''entry'' %>
> > <% form_tag ''create'', :multipart => true do
-%>
> > <p><label
for="entry_image">Image</label><br/>
> > <%= file_column_field ''entry'',
''image'' %></p>
> > <%= submit_tag ''create'' %>
> > <% end -%>
> > <%= link_to ''Back'', entries_path %>
> > ====================>
> Ran into this issue just now when moving from old rails version to
> 2.0.2.
>
> If you want to use form_tag instead of form_for, you must group your
> action and controller hash with brackets like this:
>
> form_tag( {:action => ''create''}, :multipart => true
) do
>
> Otherwise if you indicate :action with no brackets, it then thinks that
> all of your parameters belong in the same hash with :action,
> :controller, :params, etc. and puts everything you specify right into
> the querystring. I think the above would also work without parentheses.
>
> - sappworks
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On Fri, May 9, 2008 at 7:41 PM, KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <KathysKode-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I don''t mean to be a ''turd'' here, but that won''t work. Here is what it > should look like: > <%= form_tag(:url => {:action=> "create" }, :html => { :multipart => > true }) -%>Rails already knows/expects the first hash will be the :url hash and the second hash the :html.>> form_tag( {:action => ''create''}, :multipart => true ) doI, like Ben, have long prefered the perfectly acceptable (shorter) version you choose to criticize: http://destiney.com/blog/rails-form-tag -1 for failing to be a proper turd. -- Greg Donald http://destiney.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---