I am simply trying to create a plugin migration generator without any parameters, like : $rails generate yaffle
and this should copy the migration file (lib/generators/yaffle/template/create_yaffle.rb) to db/migrate/[timestamp]_create_yaffle.rb.
- The problem I am facing here is, its copying, but without timestamp.
- Also, when I run
$rails generate yaffle
it gives me a message that arguments are not provided, it expects to be in this formatrails generate yaffle NAME [options]
. I dont want to have any options/arguments, it should just berails generate yaffle
.
What should I do?
I followed the generator used in acts_as_commentable , it looks pretty simple, but I don't know where to modify these settings... can anybody help?
Generator Code:
require 'rails/generators'
require 'rails/generators/migration'
class ThumbitGenerator Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)
def self.next_migration_number(path)
Time.now.utc.strftime("%Y%m%d%H%M%S")
end
def create_model_file
template "like.rb", "app/models/like.rb"
template "liking.rb", "app/models/liking.rb"
template "create_likes.rb", "db/migrate/create_likes.rb"
template "create_likings.rb", "db/migrate/create_likings.rb"
end
end