Class: EarthDistance::Setup
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- EarthDistance::Setup
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/activerecord-postgres-earthdistance/railties.rb
Overview
Creates the earthdistance:setup generator. This generator creates a migration that adds earthdistance support for your database. If fact, it’s just the sql from the contrib inside a migration. But it’ s handy, isn’t it?
To use your generator, simply run it in your project:
rails g earthdistance:setup
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/activerecord-postgres-earthdistance/railties.rb', line 26 def self.next_migration_number(dirname) if ActiveRecord::Base. Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d".format(current_migration_number(dirname) + 1) end end |
.source_root ⇒ Object
22 23 24 |
# File 'lib/activerecord-postgres-earthdistance/railties.rb', line 22 def self.source_root @source_root ||= File.join(File.dirname(__FILE__), "..", "templates") end |
Instance Method Details
#create_migration_file ⇒ Object
34 35 36 |
# File 'lib/activerecord-postgres-earthdistance/railties.rb', line 34 def create_migration_file migration_template "setup_earthdistance.rb", "db/migrate/setup_earthdistance.rb", migration_version: migration_version end |