Module: RailsBase::RailsActions

Extended by:
FileManipulation
Included in:
Features::Chat
Defined in:
lib/rs-rails-base/rails_actions.rb

Overview

This module provides help to deal with rails migrations

Instance Method Summary collapse

Methods included from FileManipulation

append_to_file, create_file, inject_into_file, install_gem, read_all_content, replace_in_file

Methods included from CliActions

ask_for_something, #say_something

Instance Method Details

#new_migration(template_path, name) ⇒ Object



6
7
8
9
10
11
# File 'lib/rs-rails-base/rails_actions.rb', line 6

def new_migration(template_path, name)
  migration = next_migration_number
  create_file("db/migrate/#{migration}_#{name}",
              "#{template_path}#{name}")
  sleep(0.1)
end

#run_migrationsObject



13
14
15
16
17
18
19
# File 'lib/rs-rails-base/rails_actions.rb', line 13

def run_migrations
  if File.exist?('config/database.yml')
    `rake db:migrate`
  else
    say_something('Please now create a database.yml file and run `rake db:migrate`')
  end
end