hi, i''ve got a page where i''m trying to save the
user''s profile
information and an image of the user, but i''m having trouble with using
attachment_fu and the form_tag method.
now i know attachment_fu isn''t designed for form_tag but am really
hoping someone has a solution for this as frankly i''m stumped.
here''s the form_tag part in the view...
<% form_tag( { :action => "add_profile" }, { :multipart =>
true }) do %>
<%= file_field_tag ''image'', :uploaded_data %>
<%= text_area :profile, :body, :cols => 25, :rows => 6 %>
<%= submit_tag ''Submit'' %>
<% end -%>
and in the add_profile method...
def add_profile
return unless request.post?
@image = Image.new(params[:image])
@image.user_id = self.current_user.id
@image.default = true #set it to be the default photo for the user
@profile = Profile.find(self.current_user.id)
@profile.update_attributes(params[:profile])
redirect_to :action => ''profile''
end
looks like it should work and the profile part is being saved but no
image is being uploaded.
any ideas?
--
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
-~----------~----~----~----~------~----~------~--~---
On Feb 4, 2008 1:37 PM, John Griffiths <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > hi, i''ve got a page where i''m trying to save the user''s profile > information and an image of the user, but i''m having trouble with using > attachment_fu and the form_tag method. > > now i know attachment_fu isn''t designed for form_tag but am really > hoping someone has a solution for this as frankly i''m stumped. > > here''s the form_tag part in the view... > > <% form_tag( { :action => "add_profile" }, { :multipart => true }) do %> > > <%= file_field_tag ''image'', :uploaded_data %> > > <%= text_area :profile, :body, :cols => 25, :rows => 6 %> > > <%= submit_tag ''Submit'' %> > > <% end -%> > > > and in the add_profile method... > > def add_profile > return unless request.post? > > @image = Image.new(params[:image]) > @image.user_id = self.current_user.id > @image.default = true #set it to be the default photo for the user > > @profile = Profile.find(self.current_user.id) > @profile.update_attributes(params[:profile]) > redirect_to :action => ''profile'' > end > > > looks like it should work and the profile part is being saved but no > image is being uploaded.Try saving the @image instance. -- Rick Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.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 -~----------~----~----~----~------~----~------~--~---
ugh, thanks Rick, added a save method and it worked fine. i changed the filetag to... <%= file_field :image, :uploaded_data %> and in the controller added the save call.. @image.save ;-) -- 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 -~----------~----~----~----~------~----~------~--~---