Class: Mindapp::Generators::MongoidGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/mindapp/mongoid_generator.rb

Instance Method Summary collapse

Instance Method Details

#finishObject



24
25
26
27
28
29
30
31
# File 'lib/generators/mindapp/mongoid_generator.rb', line 24

def finish
  puts "Mongoid finished configured for rails 5 and heroku.\n"
  puts "Next: To set up user/password as admin/secret\n"
  puts "Please run the following command:\n"
  puts "----------------------------------------\n"
  puts "rake mindapp:seed\n"
  puts "----------------------------------------\n"
end

#setup_mongoidObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/generators/mindapp/mongoid_generator.rb', line 5

def setup_mongoid
  generate "mongoid:config"
  inject_into_file 'config/mongoid.yml', :after => '  # raise_not_found_error: true' do
    "\n    raise_not_found_error: false"
  end

  inject_into_file 'config/mongoid.yml', :after => '  # belongs_to_required_by_default: true' do
    "\n    belongs_to_required_by_default: false"
  end
  inject_into_file 'config/mongoid.yml', :after => '  # app_name: MyApplicationName' do
    "\n\nproduction:" +
        "\n  clients:" +
        "\n    default:" +
        "\n      uri: <%= ENV['MONGODB_URI'] %>" +
        "\n  options:" +
        "\n    raise_not_found_error: false" +
        "\n    belongs_to_required_by_default: false\n"
  end
end