class Todofuken::InstallGenerator

Constants

Prefectures

Public Instance Methods

create_db_seed() click to toggle source
# File lib/generators/todofuken/install/install_generator.rb, line 61
def create_db_seed
  text = "\n\n"
  text << Prefectures.map.with_index(1) do |name, idx|
    "#{class_name}.find_or_create_by(id: #{idx}, name: '#{name}')"
  end.join("\n")

  inject_into_file 'db/seeds.rb', text.force_encoding('ascii-8bit'), after: /.\Z/
end
create_migration() click to toggle source
# File lib/generators/todofuken/install/install_generator.rb, line 57
def create_migration
  generate 'model', "#{class_name} name:string --no-timestamps"
end