active_record_simple_execute 0.9.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +64 -44
- data/Rakefile +0 -9
- data/lib/active_record_simple_execute/version.rb +1 -3
- data/lib/active_record_simple_execute.rb +13 -22
- metadata +10 -114
- data/test/dummy_app/Rakefile +0 -7
- data/test/dummy_app/app/assets/config/manifest.js +0 -3
- data/test/dummy_app/app/assets/javascripts/application.js +0 -0
- data/test/dummy_app/app/assets/stylesheets/application.css +0 -3
- data/test/dummy_app/app/controllers/application_controller.rb +0 -3
- data/test/dummy_app/app/models/application_record.rb +0 -3
- data/test/dummy_app/app/models/post.rb +0 -3
- data/test/dummy_app/app/views/layouts/application.html.erb +0 -14
- data/test/dummy_app/config/application.rb +0 -70
- data/test/dummy_app/config/boot.rb +0 -10
- data/test/dummy_app/config/database.yml +0 -20
- data/test/dummy_app/config/environment.rb +0 -5
- data/test/dummy_app/config/environments/development.rb +0 -30
- data/test/dummy_app/config/environments/production.rb +0 -60
- data/test/dummy_app/config/environments/test.rb +0 -41
- data/test/dummy_app/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy_app/config/initializers/inflections.rb +0 -10
- data/test/dummy_app/config/initializers/mime_types.rb +0 -5
- data/test/dummy_app/config/initializers/secret_token.rb +0 -11
- data/test/dummy_app/config/initializers/session_store.rb +0 -8
- data/test/dummy_app/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy_app/config/locales/en.yml +0 -5
- data/test/dummy_app/config/routes.rb +0 -6
- data/test/dummy_app/config/secrets.yml +0 -22
- data/test/dummy_app/config.ru +0 -4
- data/test/dummy_app/db/migrate/20210128155312_set_up_test_tables.rb +0 -28
- data/test/dummy_app/db/test +0 -0
- data/test/dummy_app/db/test.sqlite3 +0 -0
- data/test/dummy_app/log/test.log +0 -612
- data/test/test_helper.rb +0 -43
- data/test/unit/active_record_simple_execute_test.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a104f89547cb18fd208b3cd22043bfd185cb81109522fc90f9176ff92d341858
|
4
|
+
data.tar.gz: 6aa1b61f1acbabcbebc3deb7190b4fd24a1755774a9c005cc84645511b069e9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da04345171c9cd13bee15de0f766ce34ffc8c8e356949a7bd8ae35a027feae5019c09b857ea441cc8a88fff1a66fe92b4c779b4c7a8a922316eea385afda2e69
|
7
|
+
data.tar.gz: 5f5e6f73d5e51b377e04e5a62bb06173004f33d1a4c3fac0c88f0296b0bb25ed8a23f2b5ecaa1b05df4589b86ce9562911e6935c66fe8b9d15fb21d55d5ee4a5
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,16 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
---------
|
3
3
|
|
4
|
-
- Unreleased - [View Diff](https://github.com/westonganger/active_record_simple_execute/compare/
|
4
|
+
- Unreleased - [View Diff](https://github.com/westonganger/active_record_simple_execute/compare/v1.0.0...master)
|
5
5
|
* Nothing yet
|
6
6
|
|
7
|
+
- v1.0.0 - Oct 17, 2024 - [View Diff](https://github.com/westonganger/active_record_simple_execute/compare/v0.9.1...v1.0.0)
|
8
|
+
* [#8](https://github.com/westonganger/active_record_simple_execute/pull/8) - Allow usage with different Active Record database connections
|
9
|
+
* [#7](https://github.com/westonganger/active_record_simple_execute/pull/7) - Drop support for Rails 5.1 and below
|
10
|
+
* [#5](https://github.com/westonganger/active_record_simple_execute/pull/5) - Switch from using Active Record `execute` method to `exec_query` method for better memory management
|
11
|
+
|
12
|
+
- v0.9.1 - Feb 13, 2023 - [View Diff](https://github.com/westonganger/active_record_simple_execute/compare/v0.9.0...v0.9.1)
|
13
|
+
* [#1](https://github.com/westonganger/active_record_simple_execute/pull/1) - Utilize active_record lazy loading
|
14
|
+
|
7
15
|
- v0.9.0 - May 20, 2021 - [View Diff](https://github.com/westonganger/active_record_simple_execute/compare/1546ce4...v0.9.0)
|
8
16
|
* Initial Release
|
data/README.md
CHANGED
@@ -1,83 +1,103 @@
|
|
1
1
|
# ActiveRecord Simple Execute
|
2
2
|
|
3
3
|
<a href="https://badge.fury.io/rb/active_record_simple_execute" target="_blank"><img height="21" style='border:0px;height:21px;' border='0' src="https://badge.fury.io/rb/active_record_simple_execute.svg" alt="Gem Version"></a>
|
4
|
-
<a href='https://github.com/westonganger/active_record_simple_execute/actions' target='_blank'><img src="https://github.com/westonganger/active_record_simple_execute/workflows/
|
5
|
-
<a href='https://rubygems.org/gems/active_record_simple_execute' target='_blank'><img height='21' style='border:0px;height:21px;' src='https://
|
4
|
+
<a href='https://github.com/westonganger/active_record_simple_execute/actions' target='_blank'><img src="https://github.com/westonganger/active_record_simple_execute/actions/workflows/test.yml/badge.svg?branch=master" style="max-width:100%;" height='21' style='border:0px;height:21px;' border='0' alt="CI Status"></a>
|
5
|
+
<a href='https://rubygems.org/gems/active_record_simple_execute' target='_blank'><img height='21' style='border:0px;height:21px;' src='https://img.shields.io/gem/dt/active_record_simple_execute?color=brightgreen&label=Rubygems%20Downloads' border='0' alt='RubyGems Downloads' /></a>
|
6
6
|
|
7
7
|
Sanitize and Execute your raw SQL queries in ActiveRecord and Rails with a much more intuitive and shortened syntax.
|
8
8
|
|
9
|
+
# Installation
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem "active_record_simple_execute"
|
13
|
+
```
|
14
|
+
|
9
15
|
## Comparison with Plain ActiveRecord
|
10
16
|
|
11
17
|
As seen here using `simple_execute` is much easier to remember than all the hoops plain ActiveRecord makes you jump through.
|
12
18
|
|
13
|
-
|
19
|
+
### Using `simple_execute`
|
20
|
+
```ruby
|
21
|
+
sql_str = <<~SQL.squish
|
22
|
+
SELECT * FROM orders
|
23
|
+
FROM orders
|
24
|
+
WHERE orders.company_id = :company_id AND orders.updated_by_user_id = :user_id
|
25
|
+
SQL
|
26
|
+
|
27
|
+
records = ActiveRecord::Base.connection.simple_execute(sql_str, company_id: @company.id, user_id: @user.id)
|
28
|
+
# OR use the convenience method excluding the connection portion
|
29
|
+
# ActiveRecord::Base.simple_execute(...)
|
30
|
+
```
|
31
|
+
|
32
|
+
### Using original ActiveRecord `exec_query` method
|
14
33
|
```ruby
|
15
|
-
|
34
|
+
sql_str = <<~SQL.squish
|
35
|
+
SELECT *
|
36
|
+
FROM orders
|
37
|
+
WHERE orders.company_id = :company_id AND orders.updated_by_user_id = :user_id
|
38
|
+
SQL
|
39
|
+
|
40
|
+
sanitized_sql = ActiveRecord::Base.sanitize_sql_array([sql_str, company_id: @company.id, user_id: @user.id])
|
41
|
+
|
42
|
+
result = ActiveRecord::Base.connection.exec_query(sanitized_sql)
|
43
|
+
|
44
|
+
records = result.to_a
|
45
|
+
|
46
|
+
return records
|
16
47
|
```
|
17
48
|
|
18
|
-
|
49
|
+
### Using original ActiveRecord `execute` method
|
19
50
|
```ruby
|
20
|
-
|
21
|
-
|
51
|
+
sql_str = <<~SQL.squish
|
52
|
+
SELECT *
|
53
|
+
FROM orders
|
54
|
+
WHERE orders.company_id = :company_id AND orders.updated_by_user_id = :user_id
|
55
|
+
SQL
|
22
56
|
|
23
|
-
|
57
|
+
sanitized_sql = ActiveRecord::Base.sanitize_sql_array([sql_str, company_id: @company.id, user_id: @user.id])
|
24
58
|
|
25
|
-
|
26
|
-
|
27
|
-
|
59
|
+
result = ActiveRecord::Base.connection.execute(sanitized_sql)
|
60
|
+
# OR
|
61
|
+
result = ActiveRecord::Base.connection.exec_query(sanitized_sql)
|
62
|
+
|
63
|
+
if defined?(PG::Result) && result.is_a?(PG::Result)
|
64
|
+
records = result.to_a
|
65
|
+
|
66
|
+
result.clear # to prevent memory leak
|
67
|
+
|
68
|
+
elsif defined?(Mysql2::Result) && result.is_a?(Mysql2::Result)
|
28
69
|
records = []
|
29
70
|
|
30
|
-
|
71
|
+
result.each do |row|
|
31
72
|
h = {}
|
32
73
|
|
33
|
-
|
74
|
+
result.fields.each_with_index do |field,i|
|
34
75
|
h[field] = row[i]
|
35
76
|
end
|
36
77
|
|
37
78
|
records << h
|
38
79
|
end
|
80
|
+
|
39
81
|
else
|
40
|
-
records =
|
82
|
+
records = result
|
41
83
|
end
|
42
84
|
|
43
85
|
return records
|
44
86
|
```
|
45
87
|
|
46
|
-
#
|
88
|
+
# Testing
|
47
89
|
|
48
|
-
```ruby
|
49
|
-
gem 'active_record_simple_execute'
|
50
90
|
```
|
51
|
-
|
52
|
-
# Usage
|
53
|
-
|
54
|
-
```ruby
|
55
|
-
### Example with plain SQL String
|
56
|
-
sql = <<~SQL.squish
|
57
|
-
SELECT *
|
58
|
-
FROM orders
|
59
|
-
WHERE orders.foo = 'bar'
|
60
|
-
SQL
|
61
|
-
|
62
|
-
results = ActiveRecord::Base.simple_execute(sql_str)
|
63
|
-
|
64
|
-
### Example with ActiveRecord SQL Variables
|
65
|
-
|
66
|
-
sql = <<~SQL.squish
|
67
|
-
SELECT *
|
68
|
-
FROM orders
|
69
|
-
WHERE orders.company_id = :company_id AND orders.updated_by_user_id = :user_id
|
70
|
-
SQL
|
71
|
-
|
72
|
-
results = ActiveRecord::Base.simple_execute(sql_str, company_id: @company.id, @user.id)
|
91
|
+
bundle exec rake test
|
73
92
|
```
|
74
93
|
|
75
|
-
|
76
|
-
|
77
|
-
We test multiple versions of `Rails` using the `appraisal` gem. Please use the following steps to test using `appraisal`.
|
94
|
+
We can locally test different versions of Rails using `ENV['RAILS_VERSION']`
|
78
95
|
|
79
|
-
|
80
|
-
|
96
|
+
```
|
97
|
+
export RAILS_VERSION=7.0
|
98
|
+
bundle install
|
99
|
+
bundle exec rake test
|
100
|
+
```
|
81
101
|
|
82
102
|
For quicker feedback during gem development or debugging feel free to use the provided `rake console` task. It is defined within the [`Rakefile`](./Rakefile).
|
83
103
|
|
data/Rakefile
CHANGED
@@ -1,34 +1,25 @@
|
|
1
1
|
require "active_record_simple_execute/version"
|
2
2
|
|
3
|
-
require "
|
3
|
+
require "active_support/lazy_load_hooks"
|
4
4
|
|
5
|
-
|
5
|
+
ActiveSupport.on_load(:active_record) do
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
ActiveRecord::ConnectionAdapters::DatabaseStatements.module_eval do
|
8
|
+
def simple_execute(sql_str, **sql_vars)
|
9
|
+
sanitized_sql = ActiveRecord::Base.sanitize_sql_array([sql_str, **sql_vars])
|
10
10
|
|
11
|
-
|
11
|
+
query_result = exec_query(sanitized_sql)
|
12
12
|
|
13
|
-
|
14
|
-
records = results.to_a
|
15
|
-
elsif defined?(Mysql2::Result) && results.is_a?(Mysql2::Result)
|
16
|
-
records = []
|
13
|
+
records = query_result.to_a
|
17
14
|
|
18
|
-
|
19
|
-
h = {}
|
20
|
-
|
21
|
-
results.fields.each_with_index do |field,i|
|
22
|
-
h[field] = row[i]
|
23
|
-
end
|
24
|
-
|
25
|
-
records << h
|
26
|
-
end
|
27
|
-
else
|
28
|
-
records = results
|
15
|
+
return records
|
29
16
|
end
|
17
|
+
end
|
30
18
|
|
31
|
-
|
19
|
+
ActiveRecord::Base.class_eval do
|
20
|
+
def self.simple_execute(sql_str, **sql_vars)
|
21
|
+
self.connection.simple_execute(sql_str, **sql_vars)
|
22
|
+
end
|
32
23
|
end
|
33
24
|
|
34
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record_simple_execute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Weston Ganger
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,48 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: sqlite3
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rails
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: appraisal
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
69
|
- !ruby/object:Gem::Dependency
|
112
70
|
name: warning
|
113
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,44 +94,13 @@ files:
|
|
136
94
|
- Rakefile
|
137
95
|
- lib/active_record_simple_execute.rb
|
138
96
|
- lib/active_record_simple_execute/version.rb
|
139
|
-
- test/dummy_app/Rakefile
|
140
|
-
- test/dummy_app/app/assets/config/manifest.js
|
141
|
-
- test/dummy_app/app/assets/javascripts/application.js
|
142
|
-
- test/dummy_app/app/assets/stylesheets/application.css
|
143
|
-
- test/dummy_app/app/controllers/application_controller.rb
|
144
|
-
- test/dummy_app/app/models/application_record.rb
|
145
|
-
- test/dummy_app/app/models/post.rb
|
146
|
-
- test/dummy_app/app/views/layouts/application.html.erb
|
147
|
-
- test/dummy_app/config.ru
|
148
|
-
- test/dummy_app/config/application.rb
|
149
|
-
- test/dummy_app/config/boot.rb
|
150
|
-
- test/dummy_app/config/database.yml
|
151
|
-
- test/dummy_app/config/environment.rb
|
152
|
-
- test/dummy_app/config/environments/development.rb
|
153
|
-
- test/dummy_app/config/environments/production.rb
|
154
|
-
- test/dummy_app/config/environments/test.rb
|
155
|
-
- test/dummy_app/config/initializers/backtrace_silencers.rb
|
156
|
-
- test/dummy_app/config/initializers/inflections.rb
|
157
|
-
- test/dummy_app/config/initializers/mime_types.rb
|
158
|
-
- test/dummy_app/config/initializers/secret_token.rb
|
159
|
-
- test/dummy_app/config/initializers/session_store.rb
|
160
|
-
- test/dummy_app/config/initializers/wrap_parameters.rb
|
161
|
-
- test/dummy_app/config/locales/en.yml
|
162
|
-
- test/dummy_app/config/routes.rb
|
163
|
-
- test/dummy_app/config/secrets.yml
|
164
|
-
- test/dummy_app/db/migrate/20210128155312_set_up_test_tables.rb
|
165
|
-
- test/dummy_app/db/test
|
166
|
-
- test/dummy_app/db/test.sqlite3
|
167
|
-
- test/dummy_app/log/test.log
|
168
|
-
- test/test_helper.rb
|
169
|
-
- test/unit/active_record_simple_execute_test.rb
|
170
97
|
homepage: https://github.com/westonganger/active_record_simple_execute
|
171
98
|
licenses:
|
172
99
|
- MIT
|
173
100
|
metadata:
|
174
101
|
source_code_uri: https://github.com/westonganger/active_record_simple_execute
|
175
102
|
changelog_uri: https://github.com/westonganger/active_record_simple_execute/blob/master/CHANGELOG.md
|
176
|
-
post_install_message:
|
103
|
+
post_install_message:
|
177
104
|
rdoc_options: []
|
178
105
|
require_paths:
|
179
106
|
- lib
|
@@ -181,47 +108,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
181
108
|
requirements:
|
182
109
|
- - ">="
|
183
110
|
- !ruby/object:Gem::Version
|
184
|
-
version:
|
111
|
+
version: '0'
|
185
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
113
|
requirements:
|
187
114
|
- - ">="
|
188
115
|
- !ruby/object:Gem::Version
|
189
116
|
version: '0'
|
190
117
|
requirements: []
|
191
|
-
rubygems_version: 3.
|
192
|
-
signing_key:
|
118
|
+
rubygems_version: 3.4.22
|
119
|
+
signing_key:
|
193
120
|
specification_version: 4
|
194
121
|
summary: Sanitize and Execute your raw SQL queries in ActiveRecord and Rails with
|
195
122
|
a much more intuitive and shortened syntax.
|
196
|
-
test_files:
|
197
|
-
- test/unit/active_record_simple_execute_test.rb
|
198
|
-
- test/test_helper.rb
|
199
|
-
- test/dummy_app/app/models/application_record.rb
|
200
|
-
- test/dummy_app/app/models/post.rb
|
201
|
-
- test/dummy_app/app/controllers/application_controller.rb
|
202
|
-
- test/dummy_app/app/views/layouts/application.html.erb
|
203
|
-
- test/dummy_app/app/assets/config/manifest.js
|
204
|
-
- test/dummy_app/app/assets/javascripts/application.js
|
205
|
-
- test/dummy_app/app/assets/stylesheets/application.css
|
206
|
-
- test/dummy_app/config/secrets.yml
|
207
|
-
- test/dummy_app/config/routes.rb
|
208
|
-
- test/dummy_app/config/locales/en.yml
|
209
|
-
- test/dummy_app/config/environments/production.rb
|
210
|
-
- test/dummy_app/config/environments/development.rb
|
211
|
-
- test/dummy_app/config/environments/test.rb
|
212
|
-
- test/dummy_app/config/environment.rb
|
213
|
-
- test/dummy_app/config/application.rb
|
214
|
-
- test/dummy_app/config/database.yml
|
215
|
-
- test/dummy_app/config/boot.rb
|
216
|
-
- test/dummy_app/config/initializers/backtrace_silencers.rb
|
217
|
-
- test/dummy_app/config/initializers/mime_types.rb
|
218
|
-
- test/dummy_app/config/initializers/session_store.rb
|
219
|
-
- test/dummy_app/config/initializers/wrap_parameters.rb
|
220
|
-
- test/dummy_app/config/initializers/secret_token.rb
|
221
|
-
- test/dummy_app/config/initializers/inflections.rb
|
222
|
-
- test/dummy_app/config.ru
|
223
|
-
- test/dummy_app/Rakefile
|
224
|
-
- test/dummy_app/db/test
|
225
|
-
- test/dummy_app/db/test.sqlite3
|
226
|
-
- test/dummy_app/db/migrate/20210128155312_set_up_test_tables.rb
|
227
|
-
- test/dummy_app/log/test.log
|
123
|
+
test_files: []
|
data/test/dummy_app/Rakefile
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
-
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
-
|
5
|
-
require File.expand_path('../config/application', __FILE__)
|
6
|
-
|
7
|
-
Dummy::Application.load_tasks
|
File without changes
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require File.expand_path('../boot', __FILE__)
|
2
|
-
|
3
|
-
begin
|
4
|
-
require 'warning'
|
5
|
-
Warning.ignore(
|
6
|
-
%r{mail/parsers/address_lists_parser}, ### Hide mail gem warnings
|
7
|
-
)
|
8
|
-
rescue LoadError
|
9
|
-
# Do nothing
|
10
|
-
end
|
11
|
-
|
12
|
-
require 'rails/all'
|
13
|
-
|
14
|
-
Bundler.require
|
15
|
-
|
16
|
-
module Dummy
|
17
|
-
class Application < Rails::Application
|
18
|
-
# Settings in config/environments/* take precedence over those specified here.
|
19
|
-
# Application configuration should go into files in config/initializers
|
20
|
-
# -- all .rb files in that directory are automatically loaded.
|
21
|
-
|
22
|
-
# Custom directories with classes and modules you want to be autoloadable.
|
23
|
-
# config.autoload_paths += %W(#{config.root}/extras)
|
24
|
-
|
25
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
26
|
-
# :all can be used as a placeholder for all plugins not explicitly named.
|
27
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
28
|
-
|
29
|
-
# Activate observers that should always be running.
|
30
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
31
|
-
|
32
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
33
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
34
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
35
|
-
|
36
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
37
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
38
|
-
# config.i18n.default_locale = :de
|
39
|
-
|
40
|
-
# Configure the default encoding used in templates for Ruby 1.9.
|
41
|
-
config.encoding = "utf-8"
|
42
|
-
|
43
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
44
|
-
config.filter_parameters += [:password]
|
45
|
-
|
46
|
-
# Enable the asset pipeline
|
47
|
-
config.assets.enabled = true
|
48
|
-
|
49
|
-
config.assets.quiet = true
|
50
|
-
|
51
|
-
# Version of your assets, change this if you want to expire all your assets
|
52
|
-
config.assets.version = '1.0'
|
53
|
-
|
54
|
-
config.generators.test_framework = false
|
55
|
-
config.generators.helper = false
|
56
|
-
config.generators.stylesheets = false
|
57
|
-
config.generators.javascripts = false
|
58
|
-
|
59
|
-
config.after_initialize do
|
60
|
-
ActiveRecord::Migration.migrate(Rails.root.join("db/migrate/*").to_s)
|
61
|
-
end
|
62
|
-
|
63
|
-
if ActiveRecord.respond_to?(:gem_version)
|
64
|
-
gem_version = ActiveRecord.gem_version
|
65
|
-
if gem_version.to_s.start_with?("5.2.")
|
66
|
-
config.active_record.sqlite3.represent_boolean_as_integer = true
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
default: &default
|
2
|
-
<% if defined?(SQLite3) %>
|
3
|
-
adapter: sqlite3
|
4
|
-
database: db/test.sqlite3
|
5
|
-
|
6
|
-
<% elsif defined?(Mysql2) %>
|
7
|
-
adapter: mysql2
|
8
|
-
database: active_record_simple_execute_test
|
9
|
-
|
10
|
-
<% elsif defined?(PG) %>
|
11
|
-
adapter: postgresql
|
12
|
-
database: active_record_simple_execute_test
|
13
|
-
|
14
|
-
<% end %>
|
15
|
-
|
16
|
-
development:
|
17
|
-
<<: *default
|
18
|
-
|
19
|
-
test:
|
20
|
-
<<: *default
|
@@ -1,30 +0,0 @@
|
|
1
|
-
Dummy::Application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb
|
3
|
-
|
4
|
-
# In the development environment your application's code is reloaded on
|
5
|
-
# every request. This slows down response time but is perfect for development
|
6
|
-
# since you don't have to restart the web server when you make code changes.
|
7
|
-
config.cache_classes = false
|
8
|
-
|
9
|
-
# Log error messages when you accidentally call methods on nil.
|
10
|
-
config.whiny_nils = true
|
11
|
-
|
12
|
-
# Show full error reports and disable caching
|
13
|
-
config.consider_all_requests_local = true
|
14
|
-
config.action_controller.perform_caching = false
|
15
|
-
|
16
|
-
# Don't care if the mailer can't send
|
17
|
-
config.action_mailer.raise_delivery_errors = false
|
18
|
-
|
19
|
-
# Print deprecation notices to the Rails logger
|
20
|
-
config.active_support.deprecation = :log
|
21
|
-
|
22
|
-
# Only use best-standards-support built into browsers
|
23
|
-
config.action_dispatch.best_standards_support = :builtin
|
24
|
-
|
25
|
-
# Do not compress assets
|
26
|
-
config.assets.compress = false
|
27
|
-
|
28
|
-
# Expands the lines which load the assets
|
29
|
-
config.assets.debug = true
|
30
|
-
end
|