Saturday, October 2, 2010

[Rails] How to write a test hash for a nested form??

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@gmail.com" } } }

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@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


Real Estate