how to upload a video,document and a audio (of any format) within the same controller and within the same form? is it possible to do that? if not then what is the solution? -- 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 Aug 17, 2011, at 10:37 AM, Kapil K. wrote:> how to upload a video,document and a audio (of any format) within the > same controller and within the same form? > > is it possible to do that? > > if not then what is the solution? >If you''re using Paperclip or CarrierWave, just add two separate file attributes to your base model, following the usual instructions for either. If you want to be able to attach N number of files of any format to a base model, consider the nested_form Gem by Ryan Bates, and be sure to watch his Railscast on "Complex Forms 1 & 2" to make sure you grasp what the gem is making for you. Walter> -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en > . >-- 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.
you told to me this solution> If you''re using Paperclip or CarrierWave, just add two separate file > attributes to your base model, following the usual instructions for > either. If you want to be able to attach N number of files of any > format to a base model, consider the nested_form Gem by Ryan Bates, > and be sure to watch his Railscast on "Complex Forms 1 & 2" to make > sure you grasp what the gem is making for you.but,i am the fresher please told me how to add two separate file attributes in our model? kindly give me the solution with small code? -- 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 Aug 18, 2011, at 2:30 AM, Kapil K. wrote:> you told to me this solution > >> If you''re using Paperclip or CarrierWave, just add two separate file >> attributes to your base model, following the usual instructions for >> either. If you want to be able to attach N number of files of any >> format to a base model, consider the nested_form Gem by Ryan Bates, >> and be sure to watch his Railscast on "Complex Forms 1 & 2" to make >> sure you grasp what the gem is making for you. > > but,i am the fresher please told me how to add two separate file > attributes in our model? kindly give me the solution with small code?Assuming you are using Paperclip, and you have a Foo model, and you have read the ReadMe on the Paperclip GitHub page, you would do this: rails generate paperclip Foo image_one rails generate paperclip Foo image_two rake db:migrate Now you have the proper bits in your database. If you are using attr_accessible in your model (please say yes) then you have to add :image_one, :image_two, to the beginning of the list of accessible attributes. Add has_attached_file :image_one, :styles => {} has_attached_file :image_two, :styles => {} to your model. In your view''s form_for call, add :html => { :multipart => true } before the do, so it looks like this: <%= form_for @foo, :html => { :multipart => true } do |f| %> In your form body, add a field for each image: <%= f.file_field :image_one %> <%= f.file_field :image_two %> And you''re done. Files will upload to your public/system/foos/ image_[one|two]/original/ folder, off the top of my head. You can configure EVERYTHING, just read the Wiki. Walter> > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en > . >-- 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.