Class: Rails::Generators::LocalizedActiveRecordGenerator

Inherits:
NamedBase
  • Object
show all
Defined in:
lib/generators/rails/localized_active_record/localized_active_record_generator.rb

Instance Method Summary collapse

Instance Method Details

#call_original_modelObject



11
12
13
# File 'lib/generators/rails/localized_active_record/localized_active_record_generator.rb', line 11

def call_original_model
  invoke('active_record:model', ARGV, {migration: true, timestamps: true})
end

#create_localization_fileObject



15
16
17
18
19
20
21
22
# File 'lib/generators/rails/localized_active_record/localized_active_record_generator.rb', line 15

def create_localization_file
  options[:locale].reject {|loc| loc == 'en'}
  options[:locale].insert(0, 'en')
  options[:locale].each do |loc|
    @locale = loc
    template 'localize.yml.erb', "config/locales/#{singular_name}.#{@locale}.yml"
  end
end