From dd1c8e2dd23b2f94182bf9e029a8356298b22420 Mon Sep 17 00:00:00 2001 From: Washington Botelho Date: Thu, 2 Nov 2017 13:30:22 -0200 Subject: [PATCH] refactor generator --- lib/generators/rating/install_generator.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/generators/rating/install_generator.rb b/lib/generators/rating/install_generator.rb index 5332239..84930b3 100644 --- a/lib/generators/rating/install_generator.rb +++ b/lib/generators/rating/install_generator.rb @@ -4,12 +4,16 @@ module Rating class InstallGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) - desc 'configure Rating' + desc 'creates Rating migration' def create_migration - version = Time.current.strftime('%Y%m%d%H%M%S') + template 'db/migrate/create_rating_tables.rb', "db/migrate/#{timestamp}_create_rating_tables.rb" + end - template 'db/migrate/create_rating_tables.rb', "db/migrate/#{version}_create_rating_tables.rb" + private + + def timestamp + Time.current.strftime '%Y%m%d%H%M%S' end end end