Skip to content
12 changes: 11 additions & 1 deletion lib/generators/acts_as_follower_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,21 @@ def self.next_migration_number(dirname)
end

def create_migration_file
migration_template 'migration.rb', 'db/migrate/acts_as_follower_migration.rb'
migration_template 'migration.rb', 'db/migrate/acts_as_follower_migration.rb' , migration_version: migration_version
end

def create_model
template "model.rb", File.join('app/models', "follow.rb")
end

def migration_version
if rails5?
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
end
end

def rails5?
Rails.version.start_with? '5'
end

end
2 changes: 1 addition & 1 deletion lib/generators/templates/migration.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ActsAsFollowerMigration < ActiveRecord::Migration
class ActsAsFollowerMigration < ActiveRecord::Migration<%= migration_version %>
def self.up
create_table :follows, force: true do |t|
t.references :followable, polymorphic: true, null: false
Expand Down