I have a view that passes two params hashes (:user and :school) to my controller action. In the functional test for the controller action, how do pass these two hashes? I tried the following that did not work get(:create, [:user => {:firstname => ''xxx'', :lastname => ''yyyy''}, :school => {:id => 1}] ) It seems to pick only the first array element. Anybody run into this issue and knows how to do this? -Navjeet --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
njs wrote:> I tried the following that did not work > get(:create, [:user => {:firstname => ''xxx'', :lastname => > ''yyyy''}, :school => {:id => 1}] )You are thinking too hard. Rails typically requires less effort. get :create, :user => {:firstname => ''xxx'', :lastname => ''yyyy''}, :school => {:id => 1} Now get inside def create, and add p params Run the test, and you will see how your parameters pass thru.> Anybody run into this issue and knows how to do this?Have you read /Agile Web Development with Rails/? It covers all this stuff. -- Phlip http://flea.sourceforge.net/PiglegToo_1.html --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi -- On 4/7/07, njs <navjeetc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I have a view that passes two params hashes (:user and :school) to my > controller action. In the functional test for the controller action, > how do pass these two hashes? > > I tried the following that did not work > get(:create, [:user => {:firstname => ''xxx'', :lastname => > ''yyyy''}, :school => {:id => 1}] ) > > It seems to pick only the first array element. > > Anybody run into this issue and knows how to do this?You don''t need to wrap your hashes in an array. In fact, you need not to :-) get(:create, :user => {:firstname => ''xxx'', :lastname => ''yyyy''}, :school => {:id => 1}) :user and :school are themselves hash keys, and the hash to which they belong is implicit in your argument list, based on the Ruby rule that if the last thing in an argument list is a literal hash, you can leave off the curly braces. David -- Upcoming Rails training by Ruby Power and Light: Four-day Intro to Intermediate May 8-11, 2007 Edison, NJ http://www.rubypal.com/events/05082007 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---