seems pretty simple, my model... has_attached_file :pic_1, :styles => { :thumb => "120x90" }, :url => "/:attachment/:id_:style.:extension", :path => ":rails_root/public/system/:attachment/:id_:style.:extension" my view... <% form_tag(:action => ''create'', :html => { :multipart => true }) do -%> <label for="ad_pic_1">Image</label> <%= file_field ''ad'', ''pic_1'' %> <%= submit_tag '' Save '', :class => ''button'' %> and I save and the development.log shows expected... Processing Admin::AdsController#create (for 127.0.0.1 at 2010-02-13 17:49:15) [POST] Parameters: {"html"=>{"multipart"=>"true"}, "commit"=>" Save ", "ad"=>{"salesprogram_id"=>"3", "pic_1"=>"DSC01760.JPG", "active"=>"true"}, "action"=>"create", "authenticity_token"=>"-", "controller"=>"admin/ads"} But the SQL Insert for pic_1_file_name, pic_1_file_size, pic_1_content_type and pic_1_updated_at are all NULL and I''ve googled and flailed and googled and flailed but I cannot make this work. Can anyone toss me a bone here? Craig -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Craig White wrote:> seems pretty simple, my model... > > has_attached_file :pic_1, :styles => { :thumb => "120x90" }, > :url => "/:attachment/:id_:style.:extension", > :path => ":rails_root/public/system/:attachment/:id_:style.:extension" > > my view... > > <% form_tag(:action => ''create'', :html => { :multipart => true }) do -%> > <label for="ad_pic_1">Image</label> > <%= file_field ''ad'', ''pic_1'' %> > <%= submit_tag '' Save '', :class => ''button'' %> > > and I save and the development.log shows expected... > Processing Admin::AdsController#create (for 127.0.0.1 at 2010-02-13 > 17:49:15) [POST] > Parameters: {"html"=>{"multipart"=>"true"}, "commit"=>" Save ", > "ad"=>{"salesprogram_id"=>"3", "pic_1"=>"DSC01760.JPG", > "active"=>"true"}, "action"=>"create", "authenticity_token"=>"-", > "controller"=>"admin/ads"} > > But the SQL Insert for pic_1_file_name, pic_1_file_size, > pic_1_content_type and pic_1_updated_at are all NULL > > and I''ve googled and flailed and googled and flailed but I cannot make > this work. > > Can anyone toss me a bone here? > > CraigParameters: {"html"=>{"multipart"=>"true"}, "commit"=>" Save ",> "ad"=>{"salesprogram_id"=>"3", "pic_1"=>"DSC01760.JPG", > "active"=>"true"}, "action"=>"create", "authenticity_token"=>"-", > "controller"=>"admin/ads"} actually is not what you want to see in the params hash; the value at "pic_1" should be a File object...:html isn''t an option form_tag understands; use use :multipart => true for your options hash. http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#M001729 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sun, 2010-02-14 at 02:53 +0100, Paul Harrington wrote:> Craig White wrote: > > seems pretty simple, my model... > > > > has_attached_file :pic_1, :styles => { :thumb => "120x90" }, > > :url => "/:attachment/:id_:style.:extension", > > :path => ":rails_root/public/system/:attachment/:id_:style.:extension" > > > > my view... > > > > <% form_tag(:action => ''create'', :html => { :multipart => true }) do -%> > > <label for="ad_pic_1">Image</label> > > <%= file_field ''ad'', ''pic_1'' %> > > <%= submit_tag '' Save '', :class => ''button'' %> > > > > and I save and the development.log shows expected... > > Processing Admin::AdsController#create (for 127.0.0.1 at 2010-02-13 > > 17:49:15) [POST] > > Parameters: {"html"=>{"multipart"=>"true"}, "commit"=>" Save ", > > "ad"=>{"salesprogram_id"=>"3", "pic_1"=>"DSC01760.JPG", > > "active"=>"true"}, "action"=>"create", "authenticity_token"=>"-", > > "controller"=>"admin/ads"} > > > > But the SQL Insert for pic_1_file_name, pic_1_file_size, > > pic_1_content_type and pic_1_updated_at are all NULL > > > > and I''ve googled and flailed and googled and flailed but I cannot make > > this work. > > > > Can anyone toss me a bone here? > > > > Craig > > Parameters: {"html"=>{"multipart"=>"true"}, "commit"=>" Save ", > > "ad"=>{"salesprogram_id"=>"3", "pic_1"=>"DSC01760.JPG", > > "active"=>"true"}, "action"=>"create", "authenticity_token"=>"-", > > "controller"=>"admin/ads"} actually is not what you want to see in the params hash; the value at "pic_1" should be a File object... > > :html isn''t an option form_tag understands; use use :multipart => true > for your options hash. > http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#M001729---- that''s what I get for trying to follow the examples supplied by the project...I actually caught it before I read your e-mail and indeed, you were right on the mark. The last time I did picture uploads, etc. was with Rails 1.2 & rmagick and everyone says how much better paperclip is which appears to be the case but I kept looking at the model code without ever suspecting that their sample code had the multipart => true that simply didn''t work. Thanks Craig -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.