Class: MagicLocales::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- MagicLocales::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/magic_locales/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #copy_country_seeds ⇒ Object
- #copy_mgca_initialitzer ⇒ Object
- #copy_mgca_routes ⇒ Object
- #copy_migrations ⇒ Object
Class Method Details
.next_migration_number(path) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/generators/magic_locales/install_generator.rb', line 11 def self.next_migration_number(path) unless @prev_migration_nr @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i else @prev_migration_nr += 1 end @prev_migration_nr.to_s end |
Instance Method Details
#copy_country_seeds ⇒ Object
29 30 31 |
# File 'lib/generators/magic_locales/install_generator.rb', line 29 def copy_country_seeds copy_file( "locale_seeds.rb", "db/seed_locales.rb" ) end |
#copy_mgca_initialitzer ⇒ Object
34 35 36 |
# File 'lib/generators/magic_locales/install_generator.rb', line 34 def copy_mgca_initialitzer copy_file( "magic_initializer.rb", "config/initializers/magic_logales.rb" ) end |
#copy_mgca_routes ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/generators/magic_locales/install_generator.rb', line 39 def copy_mgca_routes route <<-ROUTE scope :mgclang, module: :magic_locales do resources :locales do get "trigger/:state", action: :trigger, on: :member, as: :trigger end get "/" => "locales#index" end get "/change-locale/:locale", controller: "magic_locales/locales", action: :change_locale, as: :change_locale ROUTE end |
#copy_migrations ⇒ Object
20 21 22 |
# File 'lib/generators/magic_locales/install_generator.rb', line 20 def copy_migrations migration_template( "magic_logales_migration.rb", "db/migrate/add_magic_locales.rb" ) end |