Re: [Rails] How to add multiple user create on single form using ActiveAdmin
On Thu, Jan 26, 2012 at 14:00, Loganathan Sellapa
<loganathan.ms@gmail.com> wrote:
> I need to include a form to submit two users(same model) on same form,
Disclaimer: I haven't tried ActiveAdmin, so this is just about Rails in general.
I did something sorta like this in The Decider. The Edit Decision
view includes editable display of each Decision's Factors,
Alternatives, and Rankings. (Which should have been called Ratings
but that's another story.) These are each separate models. You can
use the app yourself at http://thedecider.herokuapp.com and see the
code at https://github.com/davearonson/thedecider/.
To do like I did, just have your Customer model say it accepts nested
attributes for users, and in your order view, use fields_for when
displaying the Users. IIRC, that was all I had to do! (Nitpick: I
don't understand why a Customer would be/have two Users. Are you sure
your model shouldn't be Shipment or Order or ServiceCall or something
like that?)
I couldn't find any good clear online documentation of how this works
and what you need to do. By experimenting, I found that Rails will
take care of the rest with its wonderful behind-the-scenes magic of
tagging things with appropriate name and id attributes in the HTML,
and interpreting those when returned, so you pretty much don't need to
do *anything*! You *can* define an attributes= method if you want,
but chances are very good that what Rails will do by default is
exactly what you want, and any attempt to provide that yourself will
just mean having write a lot of tedious code.
-Dave
--
Dave Aronson: Available Cleared Ruby on Rails Freelancer
(NoVa/DC/Remote) -- see www.DaveAronson.com, and blogs at
www.Codosaur.us, www.Dare2XL.com, www.RecruitingRants.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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home