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...@xxx.com' },
].each do |client|
puts '-----------------'
puts client.name
end
end
end
Your 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?