activeadmin-sqlpage 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/activeadmin/sqlpage.rb +17 -13
- data/lib/activeadmin/sqlpage/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41056f95acad04c5c9cd54fd785d5f7976c704de
|
4
|
+
data.tar.gz: 5c9d8f62a8299f2408abbfadd787d5b881d1f80c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97a77c12b7ed696052216881344a8c86cc7273feef346c39fa08bcd338b11357fdac0ff1a11e2ffe90de42c86218c93109bd689797a65ef9513837ee913551e7
|
7
|
+
data.tar.gz: 9d8e72d2befdf085618b765da444a9b645e1d30a8e55b26efe70ee09b8748003de5221ecc3f072a80023761841ce7c249b01eb9402bb346d89cdc4ed2a4f7efd
|
data/README.md
CHANGED
@@ -29,6 +29,9 @@ To add SQL Page to your active admin place this peace of code for example to `ap
|
|
29
29
|
```ruby
|
30
30
|
ActiveAdmin::SqlPage::register
|
31
31
|
```
|
32
|
+
|
33
|
+
Open your site at active admin page, navigate menu `SQL`, enter raw sql request in textarea, and press `Ctrl-Enter` hotkey or click `submit`.
|
34
|
+
|
32
35
|
Be carefull to execute sql requests. It may upset the consistent of your database. It is recomented to enable this page for worked project where only advanced user may have access to execute sql.
|
33
36
|
|
34
37
|
## Contributing
|
data/lib/activeadmin/sqlpage.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
B
|
2
1
|
require "activeadmin/sqlpage/version"
|
3
2
|
|
4
3
|
module ActiveAdmin
|
@@ -38,24 +37,29 @@ module ActiveAdmin
|
|
38
37
|
unless params[:sql].nil?
|
39
38
|
|
40
39
|
begin
|
41
|
-
result = ActiveRecord::Base.connection.
|
40
|
+
result = ActiveRecord::Base.connection.execute( params[:sql] )
|
41
|
+
if result
|
42
|
+
result = ActiveRecord::Result.new(result.fields, result.to_a)
|
43
|
+
end
|
42
44
|
rescue Exception => e
|
43
45
|
result = ActiveRecord::Result.new( [:error], [[e.message]] )
|
44
46
|
end
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
unless result.nil?
|
49
|
+
table class: 'index_table index' do
|
50
|
+
thead do
|
51
|
+
tr do
|
52
|
+
result.columns.each do |name|
|
53
|
+
th name, class: :col
|
54
|
+
end
|
51
55
|
end
|
52
56
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
57
|
+
tbody do
|
58
|
+
result.rows.each_with_index do |col,i|
|
59
|
+
tr class: (0==i%2?'odd':'even') do
|
60
|
+
col.each do |val|
|
61
|
+
td val, class: :col
|
62
|
+
end
|
59
63
|
end
|
60
64
|
end
|
61
65
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin-sqlpage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serguei Okladnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|