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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8b4a435b91cff0735e04185fcc4eb71560917ca
4
- data.tar.gz: 669de8b46bea9d3c912118a1cb2bd29421028374
3
+ metadata.gz: 41056f95acad04c5c9cd54fd785d5f7976c704de
4
+ data.tar.gz: 5c9d8f62a8299f2408abbfadd787d5b881d1f80c
5
5
  SHA512:
6
- metadata.gz: 752c3862c97757b70150dd4cd809e42d8a6f770bfa51deda0dcd0488a74148d184b1d4dc09ca2d8e2f4e0ea042e9a4df7ea2accd55cecfe3ce0ef0b2663818bb
7
- data.tar.gz: f651fff81c0ea5ea7e2dbb43aed54e737e58ddb1b3e6ff92d2002c8d02f6c76094b988e3a64fb2c41ba97e0ec668d4c0e67b4496ae9dab8703742c38559eb500
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
@@ -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.exec_query( params[:sql] )
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
- table class: 'index_table index' do
47
- thead do
48
- tr do
49
- result.columns.each do |name|
50
- th name, class: :col
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
- end
54
- tbody do
55
- result.rows.each_with_index do |col,i|
56
- tr class: (0==i%2?'odd':'even') do
57
- col.each do |val|
58
- td val, class: :col
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
@@ -1,5 +1,5 @@
1
1
  module ActiveAdmin
2
2
  module SqlPage
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  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.0
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-18 00:00:00.000000000 Z
11
+ date: 2016-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler