Here''s a request string which has a value I want to pull out from the category array - parent_id. Parameters: {"category"=>{"name"=>"Condiments", "parent_id"=>"1"}, "commit"=>"Create"} How do I reference that subelement in the receiving script? I''ve tried params[:parent_id] params[:category[:parent_id]] both unsuccessfully. I told you this was a stupid question. So how do I get at those values? Mike
I''d try: params[:category][:parent_id] Mike Mannakee wrote:> Here''s a request string which has a value I want to pull out from the > category array - parent_id. > > Parameters: {"category"=>{"name"=>"Condiments", "parent_id"=>"1"}, > "commit"=>"Create"} > > How do I reference that subelement in the receiving script? I''ve tried > > params[:parent_id] > params[:category[:parent_id]] > > both unsuccessfully. I told you this was a stupid question. So how do > I > get at those values? > > Mike-- Posted via http://www.ruby-forum.com/.
Hi Mike, You were close ;-) It''s params[:category][:parent_id] It''s a hash of hashes. Best regards, Bill ----- Original Message ----- From: "Mike Mannakee" <mike@basementideas.com> To: <rails@lists.rubyonrails.org> Sent: Sunday, May 07, 2006 6:49 PM Subject: [Rails] Stupid newbie question> Here''s a request string which has a value I want to pull out from the > category array - parent_id. > > Parameters: {"category"=>{"name"=>"Condiments", "parent_id"=>"1"}, > "commit"=>"Create"} > > How do I reference that subelement in the receiving script? I''ve tried > > params[:parent_id] > params[:category[:parent_id]] > > both unsuccessfully. I told you this was a stupid question. So how do I > get at those values? > > Mike > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Long version category_hash = params[:category] category_hash_parent_id = category_hash[:parent_id] As bill said it''s a hash [:category, :commit] that contains another hash[:name, :parent_id] Ross> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org]On Behalf Of Bill Walton > Sent: Monday, 8 May 2006 10:15 AM > To: rails@lists.rubyonrails.org > Subject: Re: [Rails] Stupid newbie question > > > Hi Mike, > > You were close ;-) It''s params[:category][:parent_id] > > It''s a hash of hashes. > > Best regards, > Bill > > ----- Original Message ----- > From: "Mike Mannakee" <mike@basementideas.com> > To: <rails@lists.rubyonrails.org> > Sent: Sunday, May 07, 2006 6:49 PM > Subject: [Rails] Stupid newbie question > > > > Here''s a request string which has a value I want to pull > out from the > > category array - parent_id. > > > > Parameters: {"category"=>{"name"=>"Condiments", "parent_id"=>"1"}, > > "commit"=>"Create"} > > > > How do I reference that subelement in the receiving script? > I''ve tried > > > > params[:parent_id] > > params[:category[:parent_id]] > > > > both unsuccessfully. I told you this was a stupid > question. So how do I > > get at those values? > > > > Mike > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Reasonably Related Threads
- Category and subcategories in database
- [PATCH server] fixed smart pool 'save' regression.
- acts_as_list with 2 fields in the scope
- [PATCH] v2v: -i ova: Remove incorrect warning for disks that have no parent controller (RHBZ#1167302).
- Using set_primary_key breaks acts_as_tree with non-integer column