Skip to content

Commit 902b242

Browse files
committed
Create simple view during setup.
1 parent 67bae21 commit 902b242

File tree

7 files changed

+27
-1
lines changed

7 files changed

+27
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
# Ignore bundler config.
88
/.bundle
9+
/.ruby-version
910

1011
# Ignore the default SQLite database.
1112
/db/*.sqlite3

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,9 @@ $ bundle install
1919
$ ./bin/rails db:setup
2020
```
2121

22+
We can also drop
2223

24+
```shell
25+
$ ./bin/rails db:drop:all
26+
```
2327

app/controllers/application_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class ApplicationController < ActionController::Base
44
def index
55
User.first
66
User.last
7+
Person.first
8+
Person.last
79
render html: '<h1>Test</h1>'.html_safe
810
end
911
end

app/models/person.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Person < ActiveRecord::Base
2+
end

config/environments/development.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,7 @@
5353
# Use an evented file watcher to asynchronously detect changes in source code,
5454
# routes, locales, etc. This feature depends on the listen gem.
5555
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
56+
57+
# OUR APP
58+
config.log_level = :debug
5659
end

config/environments/production.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
# Use the lowest log level to ensure availability of diagnostic information
4949
# when problems arise.
50-
config.log_level = :debug
50+
# config.log_level = :debug
5151

5252
# Prepend all log lines with the following tags.
5353
config.log_tags = [:request_id]

db/seeds.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
# This file should contain all the record creation needed to seed the database with its default values.
22
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
33

4+
@con = ActiveRecord::Base.connection
5+
6+
@con.execute "IF EXISTS (
7+
SELECT TABLE_NAME
8+
FROM INFORMATION_SCHEMA.VIEWS
9+
WHERE TABLE_NAME = 'people'
10+
) DROP VIEW people"
11+
12+
@con.execute <<-SQL
13+
CREATE VIEW people AS
14+
SELECT id, name, email
15+
FROM users
16+
SQL
17+
418
100.times do |n|
519
User.create name: "User #{n}", email: "user#{n}@example.com"
620
end

0 commit comments

Comments
 (0)