On Mar 20, 2013, at 9:04 AM, avinash behera wrote: > Upload is fine. > Suppose I am uploading five images, which I can do with file upload. > But I also need to upload those images to a specific category. I also need to > save Image name and which category(dropdown) it belongs into the db. > > Suppose I uploaded 2 images:- > After clicking on submit, I will get :- > > Image , Image Name : Text(We have to input), Category : Dropdown ---- > It will repeat
Are you trying to assign these attributes after the file is uploaded, or at the same time that you upload it? I usually follow this pattern (pseudocode!!): class Article < ActiveRecord::Base has_many :images, :dependent => :destroy accepts_nested_attributes_for :images ... end class Image < ActiveRecord::Base belongs_to :article ... end Image can have all the unique attributes -- filename, uuid, whatever else is needed by your chosen attachment library (Dragonfly, Paperclip, CarrierWave) along with the category, caption, anything else you need in your application. Using Ryan Bates' nested_form Action, you can add as many of these as you want at the time you create or edit the parent object. I recommend a quick view of the associated RailsCast: http://railscasts.com/episodes/196-nested-model-form-part-1 and http://railscasts.com/episodes/197-nested-model-form-part-2 The upshot of this construction is that you can attach as many rich (decorated) children to the parent as you need, and each one will be fully populated in a single form submission. You won't need to come back and edit the children to add the metadata to the file later (although you can if you really want to). Walter > > > On Wed, Mar 20, 2013 at 2:32 PM, Colin Law <clan...@googlemail.com> wrote: > On 20 March 2013 05:08, Avi <aavinash.beh...@gmail.com> wrote: > > Hello All, > > > > I have a requirement. > > I am uploading multiple images from a folder. > > After Submit, it should show all the images row-wise in the UI in the same > > page as :- > > Image Name : name.png > > Image Name : hello.png etc..... > > Which bit don't you know how to do? Upload? Redirect to the correct > view after upload? Fetch names from db in controller action? View > the names? > > We are not telepathic, you must ask specific questions not just ask us > how to write your application. > > Colin > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscr...@googlegroups.com. > To post to this group, send email to rubyonrails-talk@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > > > > -- > Thanks & Regards, > Avinash Behera > M-09538712979 > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscr...@googlegroups.com. > To post to this group, send email to rubyonrails-talk@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.