rails_db 1.6.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +7 -2
- data/Gemfile.lock +133 -101
- data/app/controllers/rails_db/application_controller.rb +1 -5
- data/app/controllers/rails_db/sql_controller.rb +1 -5
- data/app/controllers/rails_db/tables_controller.rb +2 -10
- data/app/helpers/rails_db/tables_helper.rb +8 -3
- data/app/views/layouts/rails_db/application.html.erb +1 -1
- data/app/views/rails_db/dashboard/data_table.html.erb +1 -1
- data/app/views/rails_db/tables/_data.html.erb +1 -1
- data/app/views/rails_db/tables/_search.html.erb +1 -1
- data/app/views/rails_db/tables/_show.html.erb +7 -11
- data/lib/ext/ransack_ext.rb +0 -0
- data/lib/rails_db/table.rb +1 -8
- data/lib/rails_db/version.rb +1 -1
- data/rails_db.gemspec +2 -6
- data/test/dashboard_controller_test.rb +6 -6
- data/test/database_test.rb +0 -3
- data/test/dummy/config/application.rb +4 -1
- data/test/dummy/config/environments/development.rb +10 -0
- data/test/dummy/config/environments/production.rb +9 -1
- data/test/dummy/config/environments/test.rb +9 -1
- data/test/dummy/config/initializers/mime_types.rb +3 -0
- data/test/dummy/db/migrate/20151013203739_create_users.rb +7 -1
- data/test/dummy/db/migrate/20151013203757_create_comments.rb +1 -1
- data/test/dummy/db/migrate/20151013204027_populate_data.rb +1 -1
- data/test/dummy/db/migrate/20151014074454_create_accounts.rb +1 -1
- data/test/dummy/db/migrate/20151014074655_create_contacts.rb +1 -1
- data/test/dummy/db/migrate/20151014152932_add_bd.rb +1 -1
- data/test/dummy/db/migrate/20151014183823_create_projects.rb +1 -1
- data/test/dummy/db/migrate/20151014184243_add_long_text.rb +1 -1
- data/test/dummy/db/migrate/20151015145740_populate_db.rb +1 -1
- data/test/dummy/db/migrate/20151027192250_create_payments.rb +1 -1
- data/test/dummy/db/migrate/20151027223149_add_non_pk_table.rb +1 -1
- data/test/dummy/db/migrate/20151028191429_create_legacy_accounts.rb +1 -1
- data/test/dummy/db/migrate/20151121125538_add_boolean_field_to_user.rb +1 -1
- data/test/dummy/db/migrate/20170126124628_add_sti_model.rb +1 -1
- data/test/dummy/db/rails_db.sqlite3 +0 -0
- data/test/dummy/db/rails_db_dev.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +72 -77
- data/test/rails_db_data_table_helper_test.rb +0 -4
- data/test/rails_db_test.rb +0 -3
- data/test/sql_import_test.rb +0 -4
- data/test/sql_query_test.rb +0 -4
- data/test/standalone/config/application.rb +4 -1
- data/test/standalone/config/environments/development.rb +10 -0
- data/test/standalone/config/environments/production.rb +9 -1
- data/test/standalone/config/environments/test.rb +9 -1
- data/test/standalone/config/initializers/mime_types.rb +3 -0
- data/test/table_test.rb +0 -1
- data/test/tables_helper_test.rb +0 -4
- data/test/test_helper.rb +1 -10
- metadata +7 -7
- data/test/standalone/config/initializers/quiet_assets.rb +0 -10
data/lib/ext/ransack_ext.rb
CHANGED
File without changes
|
data/lib/rails_db/table.rb
CHANGED
@@ -55,20 +55,13 @@ module RailsDb
|
|
55
55
|
self.table_name = table_name
|
56
56
|
self.inheritance_column = nil
|
57
57
|
end
|
58
|
-
|
58
|
+
klass.count # verify that it works, if not load other, hack
|
59
59
|
rescue
|
60
60
|
klass = ActiveRecord::Base.descendants.detect { |c| c.table_name == table_name }
|
61
61
|
end
|
62
62
|
|
63
63
|
klass.class_eval(&block) if block_given?
|
64
64
|
|
65
|
-
if Rails::VERSION::MAJOR == 3
|
66
|
-
klass.class_eval do
|
67
|
-
klass.columns.each do |e|
|
68
|
-
attr_accessor e.name
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
65
|
klass
|
73
66
|
end
|
74
67
|
|
data/lib/rails_db/version.rb
CHANGED
data/rails_db.gemspec
CHANGED
@@ -17,16 +17,12 @@ Gem::Specification.new do |s|
|
|
17
17
|
|
18
18
|
s.executables = ["railsdb", "rails_db", 'runsql']
|
19
19
|
|
20
|
-
s.add_dependency 'rails', ">=
|
20
|
+
s.add_dependency 'rails', ">= 5.0.0"
|
21
21
|
s.add_dependency 'codemirror-rails'
|
22
22
|
s.add_dependency 'terminal-table'
|
23
23
|
s.add_dependency 'simple_form'
|
24
24
|
s.add_dependency 'ransack'
|
25
|
-
|
26
|
-
s.add_dependency 'kaminari', '< 1.0.0'
|
27
|
-
else
|
28
|
-
s.add_dependency 'kaminari'
|
29
|
-
end
|
25
|
+
s.add_dependency 'kaminari'
|
30
26
|
|
31
27
|
s.add_development_dependency "launchy"
|
32
28
|
s.add_development_dependency "sqlite3"
|
@@ -64,26 +64,26 @@ class DashboardControllerTest < ActionDispatch::IntegrationTest
|
|
64
64
|
post '/rails/db/sql-xls.xls?sql=select+%2A+from+users+limit+10'
|
65
65
|
assert_equal 200, status
|
66
66
|
|
67
|
-
|
67
|
+
get '/rails/db/tables/users/edit?pk_id=' + edit_user.id.to_s, xhr: true
|
68
68
|
assert_equal 200, status
|
69
69
|
|
70
|
-
|
70
|
+
put '/rails/db/tables/users/update?pk_id=' + edit_user.id.to_s, {xhr: true, params: { record: { name: 'JOHN' }}}
|
71
71
|
assert_equal 200, status
|
72
72
|
edit_user.reload
|
73
73
|
assert_equal 'JOHN', edit_user.name
|
74
74
|
|
75
|
-
|
75
|
+
get '/rails/db/tables/users/new', xhr: true
|
76
76
|
assert_equal 200, status
|
77
77
|
|
78
78
|
assert_equal 2, User.count
|
79
|
-
|
79
|
+
post '/rails/db/tables/users/create', {xhr: true, params: { record: { name: 'XXX' }} }
|
80
80
|
assert_equal 200, status
|
81
81
|
assert_equal 3, User.count
|
82
82
|
|
83
|
-
|
83
|
+
get '/rails/db/tables/users/edit?pk_id=' + customer.id.to_s, xhr: true
|
84
84
|
assert_equal 200, status
|
85
85
|
|
86
|
-
|
86
|
+
put '/rails/db/tables/users/update?pk_id=' + customer.id.to_s, {xhr: true, params: { record: { name: 'STI' }} }
|
87
87
|
assert_equal 200, status
|
88
88
|
customer.reload
|
89
89
|
assert_equal 'STI', customer.name
|
data/test/database_test.rb
CHANGED
@@ -6,7 +6,10 @@ Bundler.require(*Rails.groups)
|
|
6
6
|
|
7
7
|
require "rails_db"
|
8
8
|
|
9
|
-
|
9
|
+
begin
|
10
|
+
Ransack::Adapters::ActiveRecord::Base.class_eval('remove_method :search')
|
11
|
+
rescue Exception
|
12
|
+
end
|
10
13
|
|
11
14
|
module Dummy
|
12
15
|
class Application < Rails::Application
|
@@ -13,6 +13,16 @@ Rails.application.configure do
|
|
13
13
|
config.consider_all_requests_local = true
|
14
14
|
config.action_controller.perform_caching = false
|
15
15
|
|
16
|
+
begin
|
17
|
+
config.serve_static_files = true
|
18
|
+
rescue NoMethodError
|
19
|
+
end
|
20
|
+
|
21
|
+
begin
|
22
|
+
config.public_file_server.enabled = true
|
23
|
+
rescue NoMethodError
|
24
|
+
end
|
25
|
+
|
16
26
|
# Don't care if the mailer can't send.
|
17
27
|
config.action_mailer.raise_delivery_errors = false
|
18
28
|
|
@@ -22,7 +22,15 @@ Rails.application.configure do
|
|
22
22
|
|
23
23
|
# Disable serving static files from the `/public` folder by default since
|
24
24
|
# Apache or NGINX already handles this.
|
25
|
-
|
25
|
+
begin
|
26
|
+
config.serve_static_files = true
|
27
|
+
rescue NoMethodError
|
28
|
+
end
|
29
|
+
|
30
|
+
begin
|
31
|
+
config.public_file_server.enabled = true
|
32
|
+
rescue NoMethodError
|
33
|
+
end
|
26
34
|
|
27
35
|
# Compress JavaScripts and CSS.
|
28
36
|
config.assets.js_compressor = :uglifier
|
@@ -16,7 +16,15 @@ Dummy::Application.configure do
|
|
16
16
|
config.eager_load = false
|
17
17
|
|
18
18
|
# Configure static file server for tests with Cache-Control for performance.
|
19
|
-
|
19
|
+
begin
|
20
|
+
config.serve_static_files = true
|
21
|
+
rescue NoMethodError
|
22
|
+
end
|
23
|
+
|
24
|
+
begin
|
25
|
+
config.public_file_server.enabled = true
|
26
|
+
rescue NoMethodError
|
27
|
+
end
|
20
28
|
#config.static_cache_control = 'public, max-age=3600'
|
21
29
|
|
22
30
|
# Show full error reports and disable caching.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class AddLongText < ActiveRecord::Migration
|
1
|
+
class AddLongText < ActiveRecord::Migration[4.2]
|
2
2
|
def change
|
3
3
|
text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris ligula arcu, commodo et mauris ut, efficitur aliquet ex. Aliquam iaculis justo maximus, dapibus nibh a, tincidunt enim. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Pellentesque hendrerit pharetra nulla, ac euismod tellus rutrum non. Ut tortor enim, tincidunt vitae pharetra quis, tincidunt sit amet felis. Sed convallis nulla sed urna finibus aliquet. Aliquam a molestie orci. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum in finibus sem, ut sagittis enim.
|
4
4
|
Sed nulla sem, suscipit sit amet lobortis eget, gravida in lectus. In sagittis urna sit amet commodo egestas. Donec vulputate, orci ac gravida congue, orci arcu facilisis ante, sed blandit quam lacus ullamcorper eros. Duis vitae sem et eros luctus tempor et ut neque. Donec at molestie quam, vel gravida velit. Etiam eu consectetur massa, sit amet vehicula risus. Nullam elementum, neque non dignissim dignissim, arcu erat lobortis orci, quis venenatis eros nibh ac risus."
|
Binary file
|
Binary file
|
data/test/dummy/db/schema.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
1
|
# This file is auto-generated from the current state of the database. Instead
|
3
2
|
# of editing this file, please use the migrations feature of Active Record to
|
4
3
|
# incrementally modify your database, and then regenerate this schema definition.
|
@@ -11,114 +10,110 @@
|
|
11
10
|
#
|
12
11
|
# It's strongly recommended that you check this file into your version control system.
|
13
12
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
13
|
+
ActiveRecord::Schema.define(version: 2017_01_26_124628) do
|
15
14
|
|
16
15
|
create_table "accounts", force: :cascade do |t|
|
17
|
-
t.string
|
18
|
-
t.integer
|
19
|
-
t.datetime "created_at",
|
20
|
-
t.datetime "updated_at",
|
16
|
+
t.string "name"
|
17
|
+
t.integer "users_count"
|
18
|
+
t.datetime "created_at", null: false
|
19
|
+
t.datetime "updated_at", null: false
|
21
20
|
end
|
22
21
|
|
23
22
|
create_table "comments", force: :cascade do |t|
|
24
|
-
t.text
|
25
|
-
t.integer
|
23
|
+
t.text "comment"
|
24
|
+
t.integer "user_id"
|
26
25
|
t.datetime "created_at", null: false
|
27
26
|
t.datetime "updated_at", null: false
|
28
27
|
end
|
29
28
|
|
30
29
|
create_table "contacts", force: :cascade do |t|
|
31
|
-
t.string
|
32
|
-
t.string
|
33
|
-
t.text
|
30
|
+
t.string "name"
|
31
|
+
t.string "email"
|
32
|
+
t.text "message"
|
34
33
|
t.datetime "created_at", null: false
|
35
34
|
t.datetime "updated_at", null: false
|
35
|
+
t.index ["name", "email"], name: "index_contacts_on_name_and_email"
|
36
36
|
end
|
37
37
|
|
38
|
-
add_index "contacts", ["name", "email"], name: "index_contacts_on_name_and_email"
|
39
|
-
|
40
38
|
create_table "legacy_accounts", primary_key: "uuid", force: :cascade do |t|
|
41
39
|
t.string "name"
|
42
40
|
end
|
43
41
|
|
44
42
|
create_table "payments", force: :cascade do |t|
|
45
|
-
t.decimal
|
46
|
-
t.integer
|
43
|
+
t.decimal "amount"
|
44
|
+
t.integer "project_id"
|
47
45
|
t.datetime "created_at", null: false
|
48
46
|
t.datetime "updated_at", null: false
|
47
|
+
t.index ["project_id"], name: "index_payments_on_project_id"
|
49
48
|
end
|
50
49
|
|
51
|
-
add_index "payments", ["project_id"], name: "index_payments_on_project_id"
|
52
|
-
|
53
50
|
create_table "projects", force: :cascade do |t|
|
54
|
-
t.string
|
55
|
-
t.string
|
56
|
-
t.string
|
57
|
-
t.string
|
58
|
-
t.string
|
59
|
-
t.string
|
60
|
-
t.string
|
61
|
-
t.string
|
62
|
-
t.string
|
63
|
-
t.string
|
64
|
-
t.string
|
65
|
-
t.string
|
66
|
-
t.string
|
67
|
-
t.string
|
68
|
-
t.string
|
69
|
-
t.string
|
70
|
-
t.string
|
71
|
-
t.string
|
72
|
-
t.string
|
73
|
-
t.string
|
74
|
-
t.string
|
75
|
-
t.integer
|
76
|
-
t.integer
|
77
|
-
t.integer
|
78
|
-
t.integer
|
79
|
-
t.integer
|
80
|
-
t.integer
|
81
|
-
t.integer
|
82
|
-
t.integer
|
83
|
-
t.integer
|
84
|
-
t.integer
|
85
|
-
t.integer
|
86
|
-
t.integer
|
87
|
-
t.integer
|
88
|
-
t.integer
|
89
|
-
t.integer
|
90
|
-
t.integer
|
91
|
-
t.integer
|
92
|
-
t.integer
|
93
|
-
t.integer
|
94
|
-
t.integer
|
95
|
-
t.datetime "created_at",
|
96
|
-
t.datetime "updated_at",
|
51
|
+
t.string "name"
|
52
|
+
t.string "description_245592"
|
53
|
+
t.string "description_450580"
|
54
|
+
t.string "description_183349"
|
55
|
+
t.string "description_341325"
|
56
|
+
t.string "description_277196"
|
57
|
+
t.string "description_943405"
|
58
|
+
t.string "description_904897"
|
59
|
+
t.string "description_267877"
|
60
|
+
t.string "description_47807"
|
61
|
+
t.string "description_713494"
|
62
|
+
t.string "description_696562"
|
63
|
+
t.string "description_976508"
|
64
|
+
t.string "description_918800"
|
65
|
+
t.string "description_27002"
|
66
|
+
t.string "description_393763"
|
67
|
+
t.string "description_960166"
|
68
|
+
t.string "description_804457"
|
69
|
+
t.string "description_684568"
|
70
|
+
t.string "description_98716"
|
71
|
+
t.string "description_337791"
|
72
|
+
t.integer "amount_584190"
|
73
|
+
t.integer "amount_898177"
|
74
|
+
t.integer "amount_599511"
|
75
|
+
t.integer "amount_308345"
|
76
|
+
t.integer "amount_572259"
|
77
|
+
t.integer "amount_562080"
|
78
|
+
t.integer "amount_684853"
|
79
|
+
t.integer "amount_77648"
|
80
|
+
t.integer "amount_377109"
|
81
|
+
t.integer "amount_246825"
|
82
|
+
t.integer "amount_91844"
|
83
|
+
t.integer "amount_787673"
|
84
|
+
t.integer "amount_158730"
|
85
|
+
t.integer "amount_331843"
|
86
|
+
t.integer "amount_540084"
|
87
|
+
t.integer "amount_780019"
|
88
|
+
t.integer "amount_745694"
|
89
|
+
t.integer "amount_715202"
|
90
|
+
t.integer "amount_887110"
|
91
|
+
t.integer "amount_607339"
|
92
|
+
t.datetime "created_at", null: false
|
93
|
+
t.datetime "updated_at", null: false
|
97
94
|
end
|
98
95
|
|
99
96
|
create_table "projects_users", id: false, force: :cascade do |t|
|
100
97
|
t.integer "project_id"
|
101
98
|
t.integer "user_id"
|
99
|
+
t.index ["project_id"], name: "index_projects_users_on_project_id"
|
100
|
+
t.index ["user_id"], name: "index_projects_users_on_user_id"
|
102
101
|
end
|
103
102
|
|
104
|
-
add_index "projects_users", ["project_id"], name: "index_projects_users_on_project_id"
|
105
|
-
add_index "projects_users", ["user_id"], name: "index_projects_users_on_user_id"
|
106
|
-
|
107
103
|
create_table "users", force: :cascade do |t|
|
108
|
-
t.string
|
109
|
-
t.integer
|
110
|
-
t.decimal
|
111
|
-
t.text
|
112
|
-
t.datetime "created_at",
|
113
|
-
t.datetime "updated_at",
|
114
|
-
t.integer
|
115
|
-
t.date
|
116
|
-
t.boolean
|
117
|
-
t.string
|
104
|
+
t.string "name"
|
105
|
+
t.integer "age"
|
106
|
+
t.decimal "salary"
|
107
|
+
t.text "bio"
|
108
|
+
t.datetime "created_at", null: false
|
109
|
+
t.datetime "updated_at", null: false
|
110
|
+
t.integer "account_id"
|
111
|
+
t.date "dob"
|
112
|
+
t.boolean "active", default: true
|
113
|
+
t.string "type"
|
114
|
+
t.index ["account_id"], name: "index_users_on_account_id"
|
115
|
+
t.index ["name"], name: "index_users_on_name"
|
116
|
+
t.index ["salary"], name: "index_users_on_salary"
|
118
117
|
end
|
119
118
|
|
120
|
-
add_index "users", ["account_id"], name: "index_users_on_account_id"
|
121
|
-
add_index "users", ["name"], name: "index_users_on_name"
|
122
|
-
add_index "users", ["salary"], name: "index_users_on_salary"
|
123
|
-
|
124
119
|
end
|