I assign an array to a hash value. When I inspect it shows the array but when I try to access the array by the hash index it is nil. Ideas? Here is the log output of the inspect hash: {:has_key=>0, :ext_array=>["Text file (.txt)<br/>", "Rich Text Format (.rtf)<br/>", "Word Document (.doc, .docx)<br/>"]} When I do: h[:ext_array] it is nil. -- 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.
Chris Habgood wrote:> I assign an array to a hash value. When I inspect it shows the array > but when I try to access the array by the hash index it is nil. > Ideas? > > Here is the log output of the inspect hash: > > {:has_key=>0, :ext_array=>["Text file (.txt)<br/>", "Rich Text Format > (.rtf)<br/>", "Word Document (.doc, .docx)<br/>"]} > > When I do: > > h[:ext_array] it is nil.If u don''t mind can u give me the whole code. -- 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.
On 18 March 2010 06:18, Me <chabgood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I assign an array to a hash value. > > h[:ext_array] it is nil.I copied your hash into IRB and it worked fine:>> h = {:has_key=>0, :ext_array=>["Text file (.txt)<br/>", "Rich Text Format(.rtf)<br/>", "Word Document (.doc, .docx)<br/>"]} => {:has_key=>0, :ext_array=>["Text file (.txt)<br/>", "Rich Text Format\n(.rtf)<br/>", "Word Document (.doc, .docx)<br/>"]}>> h[:ext_array]=> ["Text file (.txt)<br/>", "Rich Text Format\n(.rtf)<br/>", "Word Document (.doc, .docx)<br/>"]>>Can you post the code where you''re accessing h[:ext_array] and getting nil. I think you might be getting nil as the result of an expression rather than the value from the hash. -- 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.
i am getting this same exact error message when i try to do a User.find_by_username(''array''). Im have twitter users signed up on my site and i am trying to find the the users on my site from a timeline. When i try <%= User.find_by_username(''status.user.screen_name'') %> It returns nil, but if i use <%= status.user.screen_name %> it returns all the user screen names so i can not figure out what is going wrong. On Mar 18, 3:45 am, Michael Pavling <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 18 March 2010 06:18, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I assign an array to a hash value. > > > h[:ext_array] it is nil. > > I copied your hash into IRB and it worked fine:>> h = {:has_key=>0, :ext_array=>["Text file (.txt)<br/>", "Rich Text Format > > (.rtf)<br/>", "Word Document (.doc, .docx)<br/>"]} > => {:has_key=>0, :ext_array=>["Text file (.txt)<br/>", "Rich Text > Format\n(.rtf)<br/>", "Word Document (.doc, .docx)<br/>"]}>> h[:ext_array] > > => ["Text file (.txt)<br/>", "Rich Text Format\n(.rtf)<br/>", "Word > Document (.doc, .docx)<br/>"] > > > > Can you post the code where you''re accessing h[:ext_array] and getting > nil. I think you might be getting nil as the result of an expression > rather than the value from the hash.-- 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.
Take out the single quotes. On Thu, Mar 18, 2010 at 11:47 AM, mastermike2580 <mastermike14-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> i am getting this same exact error message when i try to do a > User.find_by_username(''array''). Im have twitter users signed up on my > site and i am trying to find the the users on my site from a > timeline. > > When i try <%= User.find_by_username(''status.user.screen_name'') %> It > returns nil, but if i use <%= status.user.screen_name %> it returns > all the user screen names so i can not figure out what is going wrong. > > > On Mar 18, 3:45 am, Michael Pavling <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > On 18 March 2010 06:18, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I assign an array to a hash value. > > > > > h[:ext_array] it is nil. > > > > I copied your hash into IRB and it worked fine:>> h = {:has_key=>0, > :ext_array=>["Text file (.txt)<br/>", "Rich Text Format > > > > (.rtf)<br/>", "Word Document (.doc, .docx)<br/>"]} > > => {:has_key=>0, :ext_array=>["Text file (.txt)<br/>", "Rich Text > > Format\n(.rtf)<br/>", "Word Document (.doc, .docx)<br/>"]}>> > h[:ext_array] > > > > => ["Text file (.txt)<br/>", "Rich Text Format\n(.rtf)<br/>", "Word > > Document (.doc, .docx)<br/>"] > > > > > > > > Can you post the code where you''re accessing h[:ext_array] and getting > > nil. I think you might be getting nil as the result of an expression > > rather than the value from the hash. > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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.