Zack Nathan
2010-Aug-27 07:33 UTC
Cannot convert string to integer error with arrays and hash
Ok so I am trying to read a hash of arrays and I seem to be getting a cannot convert string to integer error. Here is my code: <% @information[''food''][''servings''].each do |servings| %> <% servings[''serving''].each do |serving| %> <%= serving[''name''] %> <br/> <% end %> <% end %> Here is what the hash looks like: @parsed_response={"food"=>{"name"=>"Chicken: Breast Quarters, rotisserie, no skin or wing (Boston Market)", "id"=>"42e5699f-79cd-436c-965b-90850b26a278", "servings"=>{"serving"=>[{"name"=>"serving (4.9 oz)", "nutrients"=>{"calcium"=>nil, "satfat"=>"1", "fat"=>"4", "carb"=>"2", "fiber"=>"0", "sugar"=>"1", "protein"=>"33", "sodium"=>"480", "cholesterol"=>"85", "calories"=>"170"}}, {"name"=>"oz", "nutrients"=>{"calcium"=>nil, "satfat"=>"0.2025", "fat"=>"0.81", "carb"=>"0.405", "fiber"=>"0", "sugar"=>"0.2025", "protein"=>"6.6825", "sodium"=>"97.2", "cholesterol"=>"17.2125", "calories"=>"34.425"}}, {"name"=>"g", "nutrients"=>{"calcium"=>nil, "satfat"=>"0.00714285714286", "fat"=>"0.0285714285714", "carb"=>"0.0142857142857", "fiber"=>"0", "sugar"=>"0.00714285714286", "protein"=>"0.235714285714", "sodium"=>"3.42857142857", "cholesterol"=>"0.607142857143", "calories"=>"1.21428571429"}}]}}}, @response=#<Net::HTTPOK 200 OK readbody=true>, @headers={"expires"=>["0"], "last-modified"=>["Fri, 27 Aug 2010 07:30:52 GMT"], "connection"=>["close"], "content-type"=>["application/xml"], "date"=>["Fri, 27 Aug 2010 07:30:52 GMT"], "server"=>["Apache"], "cache-control"=>["pre-check=0, post-check=0, max-age=0"], "pragma"=>["no-cache"], "transfer-encoding"=>["chunked"]} Many thanks, Jakx12 -- Posted via http://www.ruby-forum.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-/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.
Try @information[0][''food''] etc etc, or iterate through @information with .each if you have multiple responses. On Aug 27, 9:33 am, Zack Nathan <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Ok so I am trying to read a hash of arrays and I seem to be getting a > cannot convert string to integer error. Here is my code: > > <% @information[''food''][''servings''].each do |servings| %> > <% servings[''serving''].each do |serving| %> > <%= serving[''name''] %> > <br/> > <% end %> > <% end %> > > Here is what the hash looks like: > @parsed_response={"food"=>{"name"=>"Chicken: Breast Quarters, > rotisserie, no skin or wing (Boston Market)", > "id"=>"42e5699f-79cd-436c-965b-90850b26a278", > "servings"=>{"serving"=>[{"name"=>"serving (4.9 oz)", > "nutrients"=>{"calcium"=>nil, "satfat"=>"1", "fat"=>"4", "carb"=>"2", > "fiber"=>"0", "sugar"=>"1", "protein"=>"33", "sodium"=>"480", > "cholesterol"=>"85", "calories"=>"170"}}, {"name"=>"oz", > "nutrients"=>{"calcium"=>nil, "satfat"=>"0.2025", "fat"=>"0.81", > "carb"=>"0.405", "fiber"=>"0", "sugar"=>"0.2025", "protein"=>"6.6825", > "sodium"=>"97.2", "cholesterol"=>"17.2125", "calories"=>"34.425"}}, > {"name"=>"g", "nutrients"=>{"calcium"=>nil, > "satfat"=>"0.00714285714286", "fat"=>"0.0285714285714", > "carb"=>"0.0142857142857", "fiber"=>"0", "sugar"=>"0.00714285714286", > "protein"=>"0.235714285714", "sodium"=>"3.42857142857", > "cholesterol"=>"0.607142857143", "calories"=>"1.21428571429"}}]}}}, > @response=#<Net::HTTPOK 200 OK readbody=true>, > @headers={"expires"=>["0"], "last-modified"=>["Fri, 27 Aug 2010 07:30:52 > GMT"], "connection"=>["close"], "content-type"=>["application/xml"], > "date"=>["Fri, 27 Aug 2010 07:30:52 GMT"], "server"=>["Apache"], > "cache-control"=>["pre-check=0, post-check=0, max-age=0"], > "pragma"=>["no-cache"], "transfer-encoding"=>["chunked"]} > > Many thanks, > > Jakx12 > -- > Posted viahttp://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Colin Law
2010-Aug-27 08:11 UTC
Re: Cannot convert string to integer error with arrays and hash
On 27 August 2010 08:33, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Ok so I am trying to read a hash of arrays and I seem to be getting a > cannot convert string to integer error. Here is my code: > > <% @information[''food''][''servings''].each do |servings| %> > <% servings[''serving''].each do |serving| %> > <%= serving[''name''] %> > <br/> > <% end %> > <% end %> > > Here is what the hash looks like: > @parsed_response={"food"=>{"name"=>"Chicken: Breast Quarters,I presume this is actually @information rather than @parsed_response (or the other way around).> rotisserie, no skin or wing (Boston Market)", > "id"=>"42e5699f-79cd-436c-965b-90850b26a278", > "servings"=>{"serving"=>[{"name"=>"serving (4.9 oz)",serving is an array (the square bracket is a giveaway) so you must use an integer to index it not ''name'' as you are doing. You can do serving[0][''name''] or use serving.each Colin> "nutrients"=>{"calcium"=>nil, "satfat"=>"1", "fat"=>"4", "carb"=>"2", > "fiber"=>"0", "sugar"=>"1", "protein"=>"33", "sodium"=>"480", > "cholesterol"=>"85", "calories"=>"170"}}, {"name"=>"oz", > "nutrients"=>{"calcium"=>nil, "satfat"=>"0.2025", "fat"=>"0.81", > "carb"=>"0.405", "fiber"=>"0", "sugar"=>"0.2025", "protein"=>"6.6825", > "sodium"=>"97.2", "cholesterol"=>"17.2125", "calories"=>"34.425"}}, > {"name"=>"g", "nutrients"=>{"calcium"=>nil, > "satfat"=>"0.00714285714286", "fat"=>"0.0285714285714", > "carb"=>"0.0142857142857", "fiber"=>"0", "sugar"=>"0.00714285714286", > "protein"=>"0.235714285714", "sodium"=>"3.42857142857", > "cholesterol"=>"0.607142857143", "calories"=>"1.21428571429"}}]}}}, > @response=#<Net::HTTPOK 200 OK readbody=true>, > @headers={"expires"=>["0"], "last-modified"=>["Fri, 27 Aug 2010 07:30:52 > GMT"], "connection"=>["close"], "content-type"=>["application/xml"], > "date"=>["Fri, 27 Aug 2010 07:30:52 GMT"], "server"=>["Apache"], > "cache-control"=>["pre-check=0, post-check=0, max-age=0"], > "pragma"=>["no-cache"], "transfer-encoding"=>["chunked"]}-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Zack Nathan
2010-Aug-27 08:13 UTC
Re: Cannot convert string to integer error with arrays and h
CU wrote:> Try @information[0][''food''] etc etc, or iterate through @information > with .each if you have multiple responses.Thanks. However @information[0] doesnt work nor are there multiple responses. What do you think I should do? -- Posted via http://www.ruby-forum.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-/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.
Zack Nathan
2010-Aug-27 08:20 UTC
Re: Cannot convert string to integer error with arrays and h
Colin Law wrote:> On 27 August 2010 08:33, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Here is what the hash looks like: >> @parsed_response={"food"=>{"name"=>"Chicken: Breast Quarters, > > I presume this is actually @information rather than @parsed_response > (or the other way around). > >> rotisserie, no skin or wing (Boston Market)", >> "id"=>"42e5699f-79cd-436c-965b-90850b26a278", >> "servings"=>{"serving"=>[{"name"=>"serving (4.9 oz)", > > serving is an array (the square bracket is a giveaway) so you must use > an integer to index it not ''name'' as you are doing. You can do > serving[0][''name''] or use serving.each > > ColinSo like this? <% @information[''food''][''servings''].each do |servings| %> <% servings[''serving''].each do |serving| %> <% serving.each do |s| %> <% portions << s[''name''] %> <%= s[''name''] %> <br/> <% end %> <% end %> Thankyou -- Posted via http://www.ruby-forum.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-/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.
Ah, I copied and pasted your inspect output and assigned it to a variable, and Rails recreated it as a hash, so it worked when I tried it. Glad you came right. On Aug 27, 10:20 am, Zack Nathan <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: > > On 27 August 2010 08:33, Zack Nathan <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> Here is what the hash looks like: > >> @parsed_response={"food"=>{"name"=>"Chicken: Breast Quarters, > > > I presume this is actually @information rather than @parsed_response > > (or the other way around). > > >> rotisserie, no skin or wing (Boston Market)", > >> "id"=>"42e5699f-79cd-436c-965b-90850b26a278", > >> "servings"=>{"serving"=>[{"name"=>"serving (4.9 oz)", > > > serving is an array (the square bracket is a giveaway) so you must use > > an integer to index it not ''name'' as you are doing. You can do > > serving[0][''name''] or use serving.each > > > Colin > > So like this? > <% @information[''food''][''servings''].each do |servings| %> > <% servings[''serving''].each do |serving| %> > <% serving.each do |s| %> > <% portions << s[''name''] %> > <%= s[''name''] %> > <br/> > <% end %> > <% end %> > > Thankyou > -- > Posted viahttp://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Zack Nathan
2010-Aug-27 08:38 UTC
Re: Cannot convert string to integer error with arrays and h
I just realised i still get the error even with that code! HELP!!! :P -- Posted via http://www.ruby-forum.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-/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.
Colin Law
2010-Aug-27 10:13 UTC
Re: Re: Cannot convert string to integer error with arrays and h
On 27 August 2010 09:38, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I just realised i still get the error even with that code! HELP!!! :PPlease quote the message you are replying to. Which code? Please post the code again and the error along with which line the error is on. First though have a look yourself and try and work it out. Colin -- 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.
Zack Nathan
2010-Aug-28 09:44 UTC
Re: Re: Cannot convert string to integer error with arrays a
Colin Law wrote:> On 27 August 2010 09:38, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> I just realised i still get the error even with that code! HELP!!! :P > > Please quote the message you are replying to. Which code? > > Please post the code again and the error along with which line the > error is on. First though have a look yourself and try and work it > out. > > ColinIts ok, I worked it out late last night, thanks though! But how would I put the display name and then the ids into a collection for a collection_select menu. Im stuck on this because I only know how to put data into a one dimensional array in ruby at the moment. Thanks, zack. -- Posted via http://www.ruby-forum.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-/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.
Colin Law
2010-Aug-28 10:30 UTC
Re: Re: Re: Cannot convert string to integer error with arrays a
On 28 August 2010 10:44, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: >> On 27 August 2010 09:38, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> I just realised i still get the error even with that code! HELP!!! :P >> >> Please quote the message you are replying to. Which code? >> >> Please post the code again and the error along with which line the >> error is on. First though have a look yourself and try and work it >> out. >> >> Colin > > Its ok, I worked it out late last night, thanks though! But how would I > put the display name and then the ids into a collection for a > collection_select menu. Im stuck on this because I only know how to put > data into a one dimensional array in ruby at the moment.You need to be more exlicit about exactly what the problem is. I presume you have looked at collection_select docs and googled for examples and have understood those (if you don''t understand the examples then persevere until you do). Find an example that is close to what you want and try and modify it for your requirement. If you cannot work out exactly what to do then post the best guess that you have for the code and explain what is going wrong. If your problem is a basic Ruby issue then study a good book on Ruby. The Pickaxe book is generally considered the one to get I think. Also you must know what html you are trying to generate, if you do not know that then study up on html. Colin -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Zack Nathan
2010-Aug-28 11:23 UTC
Re: Re: Re: Cannot convert string to integer error with arra
Colin Law wrote:> On 28 August 2010 10:44, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> Colin >> >> Its ok, I worked it out late last night, thanks though! But how would I >> put the display name and then the ids into a collection for a >> collection_select menu. Im stuck on this because I only know how to put >> data into a one dimensional array in ruby at the moment. > > You need to be more exlicit about exactly what the problem is. I > presume you have looked at collection_select docs and googled for > examples and have understood those (if you don''t understand the > examples then persevere until you do). Find an example that is close > to what you want and try and modify it for your requirement. If you > cannot work out exactly what to do then post the best guess that you > have for the code and explain what is going wrong. If your problem is > a basic Ruby issue then study a good book on Ruby. The Pickaxe book > is generally considered the one to get I think. Also you must know > what html you are trying to generate, if you do not know that then > study up on html. > > ColinThanks. Yeah i need a collection_select (a drop down menu in html) that will have the serving name as the name and also as the value. Now I dont know how I would do this in ruby, but I know how I would do this in other languages. That is my question. Thanks, jakx12. -- Posted via http://www.ruby-forum.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-/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.
Colin Law
2010-Aug-28 12:30 UTC
Re: Re: Re: Re: Cannot convert string to integer error with arra
On 28 August 2010 12:23, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: >> On 28 August 2010 10:44, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>> Colin >>> >>> Its ok, I worked it out late last night, thanks though! But how would I >>> put the display name and then the ids into a collection for a >>> collection_select menu. Im stuck on this because I only know how to put >>> data into a one dimensional array in ruby at the moment. >> >> You need to be more exlicit about exactly what the problem is. I >> presume you have looked at collection_select docs and googled for >> examples and have understood those (if you don''t understand the >> examples then persevere until you do). Find an example that is close >> to what you want and try and modify it for your requirement. If you >> cannot work out exactly what to do then post the best guess that you >> have for the code and explain what is going wrong. If your problem is >> a basic Ruby issue then study a good book on Ruby. The Pickaxe book >> is generally considered the one to get I think. Also you must know >> what html you are trying to generate, if you do not know that then >> study up on html. >> >> Colin > > Thanks. Yeah i need a collection_select (a drop down menu in html) that > will have the serving name as the name and also as the value. Now I dont > know how I would do this in ruby, but I know how I would do this in > other languages. That is my question.So have you looked at the docs and googled for examples of collection_select and made sure you understand them, as I suggested? Colin -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Zack Nathan
2010-Aug-28 12:43 UTC
Re: Re: Re: Re: Cannot convert string to integer error with
Colin Law wrote:> On 28 August 2010 12:23, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> presume you have looked at collection_select docs and googled for >>> Colin >> >> Thanks. Yeah i need a collection_select (a drop down menu in html) that >> will have the serving name as the name and also as the value. Now I dont >> know how I would do this in ruby, but I know how I would do this in >> other languages. That is my question. > > So have you looked at the docs and googled for examples of > collection_select and made sure you understand them, as I suggested? > > Colinof course! I have found this snippet of code and im trying to get it to work: <%= select("group_users", "group_id", @groups.collect {|p| [ p.group.name, p.group.id ] }, { :include_blank => true }) %> But i cant seem to get it to work at the moment. -- Posted via http://www.ruby-forum.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-/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.
Colin Law
2010-Aug-28 12:56 UTC
Re: Re: Re: Re: Re: Cannot convert string to integer error with
On 28 August 2010 13:43, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> ... > of course! I have found this snippet of code and im trying to get it to > work: > <%= select("group_users", "group_id", @groups.collect {|p| [ > p.group.name, p.group.id ] }, { :include_blank => true }) %> > > But i cant seem to get it to work at the moment.I thought you were trying to use collection_select Colin -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Zack Nathan
2010-Aug-28 13:03 UTC
Re: Re: Re: Re: Re: Cannot convert string to integer error w
Colin Law wrote:> On 28 August 2010 13:43, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> ... >> of course! I have found this snippet of code and im trying to get it to >> work: >> �<%= select("group_users", "group_id", @groups.collect {|p| [ >> p.group.name, p.group.id ] }, { :include_blank => true }) %> >> >> But i cant seem to get it to work at the moment. > > I thought you were trying to use collection_select > > ColinSo did I until I found this. Whichever one works is fine with me :P ! Jakx12. -- Posted via http://www.ruby-forum.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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Colin Law
2010-Aug-28 13:13 UTC
Re: Re: Re: Re: Re: Re: Cannot convert string to integer error w
On 28 August 2010 14:03, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: >> On 28 August 2010 13:43, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> ... >>> of course! I have found this snippet of code and im trying to get it to >>> work: >>> �<%= select("group_users", "group_id", @groups.collect {|p| [ >>> p.group.name, p.group.id ] }, { :include_blank => true }) %> >>> >>> But i cant seem to get it to work at the moment. >> >> I thought you were trying to use collection_select >> >> Colin > > So did I until I found this. Whichever one works is fine with me :P !Use collection_select, it does more for you. By the way why have we got lots of Re:Re: in the subject? Are you not just replying to the previous post? Colin -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote:> On 28 August 2010 14:03, Zack Nathan <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> I thought you were trying to use collection_select >>> >>> Colin >> >> So did I until I found this. Whichever one works is fine with me :P ! > > Use collection_select, it does more for you. > > By the way why have we got lots of Re:Re: in the subject? Are you not > just replying to the previous post? > > ColinNot sure to be honest.. -- Posted via http://www.ruby-forum.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-/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.