Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 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,23 @@ 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 rails5?
Rails.version.start_with? '5'
end
def migration_version
if rails5?
"[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
else
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"

end
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