bcparanj-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jul-02 18:38 UTC
Input text fields in multiple records of the same model
I have a form where the user can view a list of line items that has description (read only) and quantity (input field). Can someone please give me pointers on how to allow users to enter the quantity for the line items they want and save it in the database? I also need to validate to make sure that they enter integers only. TIA. --~--~---------~--~----~------------~-------~--~----~ 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 2 Lip, 20:38, "bcpar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <bcpar...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a form where the user can view a list of line items that has > description (read only) and quantity (input field). Can someone please > give me pointers on how to allow users to enter the quantity for the > line items they want and save it in the database? I also need to > validate to make sure that they enter integers only. TIA.Check this tutorial: http://www.stephenchu.com/2008/03/paramsfu-5-update-multiple-models-in.html (the whole series is really great). Basically you can do something like: @models = Model.update([array_of_ids], [{:attribute => value_for_first_object}, {:attribute => value_for_second_object},...]) Then you can iterate over @models to check for errors on returned objects. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---