Problems with Rails 3 Generators 'invoke' and migration templates

Angelegt von suung Fri, 03 Dec 2010 14:47:00 GMT

I want to generate migrations.

It seems, nobody has ever thought about that because in Rails 3 there is idea, that I have to create the timestamp on my own like this:

 

def self.next_migration_number(dirname) if ActiveRecord::Base.timestamped_migrations Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end

So some people suggest another solution

class ActsAsTaggableOnMigrationGenerator < Rails::Generators::Base

 

    invoke "migration", %(add_fields_to_tags name:string label:string)
  end

but that really does not work for me, it leads to

 

/usr/lib/ruby/gems/1.8/gems/activesupport-3.0.1/lib/active_support/whiny_nil.rb:48:in `method_missing': undefined method `name' for nil:NilClass (NoMethodError)

from /usr/lib/ruby/gems/1.8/gems/thor-0.14.4/lib/thor/invocation.rb:116:in `invoke_task'

from /usr/lib/ruby/gems/1.8/gems/thor-0.14.4/lib/thor/group.rb:224:in `dispatch'

from /usr/lib/ruby/gems/1.8/gems/thor-0.14.4/lib/thor/invocation.rb:109:in `send'

from /usr/lib/ruby/gems/1.8/gems/thor-0.14.4/lib/thor/invocation.rb:109:in `invoke'

:)

Update:

This worked:

invoke "migration", "add_fields_to_tags" "name:string label:string")

Trackbacks

Verwenden Sie den folgenden Link zur Rückverlinkung von Ihrer eigenen Seite:
http://praktikanten.brueckenschlaeger.org/trackbacks?article_id=391

Leave a comment

Comments