Class: DeviseSociableGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/devise_sociable/devise_sociable_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/generators/devise_sociable/devise_sociable_generator.rb', line 14

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

.orm_has_migration?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/generators/devise_sociable/devise_sociable_generator.rb', line 10

def self.orm_has_migration?
  Rails::Generators.options[:rails][:orm] == :active_record
end

.source_rootObject



6
7
8
# File 'lib/generators/devise_sociable/devise_sociable_generator.rb', line 6

def self.source_root
  @_devise_source_root ||= File.expand_path("../templates", __FILE__)
end

Instance Method Details

#create_migration_fileObject



26
27
28
# File 'lib/generators/devise_sociable/devise_sociable_generator.rb', line 26

def create_migration_file
  migration_template 'migration.rb', "db/migrate/devise_add_sociable_#{name.downcase}.rb"
end