How to write a hash for a nested form?? Example form fields (main model is Practice, nested is User): practice[name] practice[users_attributes][0][email] I want to do this: post: post :create, :practice => { :name => "any name", :users_attributes => { :0 => { :email => "anyone-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" } } } The issue is that I can not create a symbol for 0 - :0 and :0.to_sym don''t work and "0".to_sym and ''0''.to_sym give me the weird :"0". So how can I hack this through? Is there another way to create such a hash which bypasses need for symbols which the controller will still understand? Thanks, David -- 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.
Robert Pankowecki (rupert)
2010-Oct-03 08:57 UTC
Re: How to write a test hash for a nested form??
You do not need it to be symbols I guess. I think that string will work just fine. Anyway. You can create symbols also this way: :"123" Robert Pankowecki -- 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.
Thanks Robert, that worked great. Just looks a little weird at first to do :"0". On Sun, Oct 3, 2010 at 3:57 AM, Robert Pankowecki (rupert) < robert.pankowecki-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You do not need it to be symbols I guess. I think that string will > work just fine. > Anyway. You can create symbols also this way: > > :"123" > > Robert Pankowecki > > -- > 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<rubyonrails-talk%2Bunsubscribe-/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.
Reasonably Related Threads
- Date parse - month and day reversed
- current_page? inside controller
- Did rails or shoulda go insane on the inflection of 'taxes'?
- update_attributes updates data from second instance of nested form but not the first
- Rais 3, nested attributes problem with paperclip