Dear friends, What is different between these two array method. First Array Method arr = ps_array["1"] arr += ps_array["2"] arr += ps_array["3"] Second Array Method arr = [ps_array["1"],ps_array["2"],ps_array["3"]] yours, phoesan -- 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-US.
On 2 July 2012 09:59, phoe san <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Dear friends, > > What is different between these two array method. > > First Array Method > > arr = ps_array["1"]What is the type of ps_array["1"] Colin> arr += ps_array["2"] > arr += ps_array["3"] > > > Second Array Method > > arr = [ps_array["1"],ps_array["2"],ps_array["3"]] > > > yours, > > phoesan > > -- > 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-US. >-- 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-US.
<%= collection_select(:sport_name,count,Sport.find( :all, :order => ''id'' ), :id, :sport_name, {:selected =>@sport_id})%> Collection_select Value. We take data from collection_select by params[:sport_name] In Controller, we use this ps_array = params[:sport_name] we get the data First array method , It doesn''t work. Second Method , It Work. Regards, phoesan -- 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-US.
Hi, + operator won''t works in array I think but used as concatenation in staring. Second scenario of your case works fine. Thanks, senthil On Monday, 2 July 2012 14:29:57 UTC+5:30, Ruby-Forum.com User wrote:> > Dear friends, > > What is different between these two array method. > > First Array Method > > arr = ps_array["1"] > arr += ps_array["2"] > arr += ps_array["3"] > > > Second Array Method > > arr = [ps_array["1"],ps_array["2"],ps_array["3"]] > > > yours, > > phoesan > > -- > 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 view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/iSs267Q5HWYJ. 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-US.
On 2 July 2012 10:26, phoe san <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> <%= collection_select(:sport_name,count,Sport.find( :all, :order => ''id'' > ), > :id, :sport_name, {:selected =>@sport_id})%> > > Collection_select Value. > We take data from collection_select by params[:sport_name] > > In Controller, we use this > ps_array = params[:sport_name] > we get the data > > First array method , It doesn''t work. > Second Method , It Work.Please remember to quote the previous message, remember this is a mailing list not a forum (though you may be accessing it via a forum interface). Now we will have to look back at the previous message to see your methods. When you say arr = ps_array["1"] arr is probably a string not an array, so then when you use arr += ps_array["2"] it will concatenate the second string onto the first. Have a look at the Rails Guide on debugging for ideas on how to debug your code so that you can work out what is going on when you have this sort of problem. 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-US.
Hi Sentil and Colin, á‚ŠThank for your reply message and solution! phoesan -- 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-US.