Hi
I just installed rails 3 (3.0.3) and am trying to create a rake task.
I am seeing this:
rake aborted!
undefined method `name'' for #<Hash:0x102ea4a68>
my rake task (simplified) is as follows:
namespace :app do
desc ''Create dummy data''
task :setup => :environment do
[
{ :name => ''Test User'', :email =>
''test-q89RzV0OsXQ@public.gmane.org'' },
].each do |client|
puts ''-----------------''
puts client.name
end
end
end
Its barfing on that puts client.name
This appears to be an older bug. The solution hinted at here
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/d3e6af81dcbcce31/fded05c2c519a31f?lnk=gst&q=rake+aborted!+undefined+method+`name''+for+%23%3CHash#fded05c2c519a31f
is not working for me as rails 3 has a strong dependency on rake
0.8.7.
Anyone else seeing this problem?
--
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 12 January 2011 16:45, Billy <fowkswe-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi > > I just installed rails 3 (3.0.3) and am trying to create a rake task. > I am seeing this: > > rake aborted! > undefined method `name'' for #<Hash:0x102ea4a68> > > my rake task (simplified) is as follows: > > namespace :app do > desc ''Create dummy data'' > task :setup => :environment do > [ > { :name => ''Test User'', :email => ''test-q89RzV0OsXQ@public.gmane.org'' }, > ].each do |client| > puts ''-----------------'' > puts client.nameShould that be client[:name] Colin> end > end > end > > Its barfing on that puts client.name > > This appears to be an older bug. The solution hinted at here > > http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/d3e6af81dcbcce31/fded05c2c519a31f?lnk=gst&q=rake+aborted!+undefined+method+`name''+for+%23%3CHash#fded05c2c519a31f > > is not working for me as rails 3 has a strong dependency on rake > 0.8.7. > > Anyone else seeing this problem? > > > -- > 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. > >-- 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.
Frederick Cheung
2011-Jan-12 22:30 UTC
Re: undefined method ''xxx'' for {}:Hash rake db:migrate
On Jan 12, 4:45 pm, Billy <fowk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi > > I just installed rails 3 (3.0.3) and am trying to create a rake task. > I am seeing this: > > rake aborted! > undefined method `name'' for #<Hash:0x102ea4a68> > > my rake task (simplified) is as follows: > > namespace :app do > desc ''Create dummy data'' > task :setup => :environment do > [ > { :name => ''Test User'', :email => ''t...-q89RzV0OsXQ@public.gmane.org'' }, > ].each do |client| > puts ''-----------------'' > puts client.name > end > end > endYour code just looks wrong to me - you''re iterating over an array of hashes, so client is a hash. Hashes don''t have a name method so client.name blows up. Did you mean client[:name] or intend to use that data to create an active record object first? Fred> > Its barfing on that puts client.name > > This appears to be an older bug. The solution hinted at here > > http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/...name''+for+%23%3CHash#fded05c2c519a31f > > is not working for me as rails 3 has a strong dependency on rake > 0.8.7. > > Anyone else seeing this problem?-- 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.