undefined method `last' for {}:Hash
Posted on
02/22/2008
by
Colin
4 Comments
Sometimes you hate the things that make your life so easy, because you have some problems with those things that make it temporarily more difficult. But then you fix the problems, and everything's back to being cool again.
In this case, I'm using Engines with Ruby on Rails, and there seems to be a conflict between my version of rake and my version of engines. So I did a rake db:migrate and got the ugly-looking:
undefined method `last' for {}:Hash
on line 10 of the rakefile. Well, after some Googling and clicking through, I found that all I needed to do was update a few lines of the engines code. In /vendor/plugins/engines/tasks/engines.rake, change the redefine_task method to read as follows:
def redefine_task(task_class, args, &block)
task_name, deps = (RAKEVERSION >= '0.8.0') ? resolve_args([args]) : resolve_args(args)
task_name = task_class.scope_name(@scope, task_name)
deps = [deps] unless deps.respond_to?(:to_ary)
deps = deps.collect {|d| d.to_s }
task = @tasks[task_name.to_s] = task_class.new(task_name, self)
task.application = self
if RAKEVERSION >= '0.8.0'
task.add_description(@last_description)
@last_description = nil
else
task.add_comment(@last_comment)
@last_comment = nil
end
task.enhance(deps, &block)
task
end
Comments
Posted by Roderic on April 11, 2008
This code doesn't handle prerequisities well. resolveargs returns now triplet of [taskname, arg_names, deps], so code should be: def redefinetask(taskclass, args, &block) taskname, argnames, deps = (RAKEVERSION >= '0.8.0') ? resolveargs([args]) : resolveargs(args) ... ...
or even
def redefinetask(taskclass, *args, &block) taskname, argnames, deps = resolve_args(args) ... ...
Post a Comment
Space Highlight

I created a site for my trumpet playing and teaching - check it out. I play for weddings and other events!
Please wait…
Loading recent Flickr images...


Posted by Joel Nylund on March 04, 2008
Hi, did you mean to remove the add.comment from outside the if statement?