rails_db 0.8 → 0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +6 -1
- data/app/assets/javascripts/rails_db/application.js +1 -1
- data/app/assets/stylesheets/rails_db/app.css.scss +4 -0
- data/app/assets/stylesheets/rails_db/application.css +1 -0
- data/app/assets/stylesheets/rails_db/forms.css.scss +9 -0
- data/app/assets/stylesheets/rails_db/table.css.scss +1 -1
- data/app/controllers/rails_db/application_controller.rb +0 -1
- data/app/controllers/rails_db/sql_controller.rb +6 -6
- data/app/controllers/rails_db/tables_controller.rb +50 -15
- data/app/views/layouts/rails_db/application.html.erb +1 -0
- data/app/views/rails_db/dashboard/index.html.erb +1 -0
- data/app/views/rails_db/tables/_data.html.erb +3 -13
- data/app/views/rails_db/tables/_edit.html.erb +25 -0
- data/app/views/rails_db/tables/_row.html.erb +15 -0
- data/app/views/rails_db/tables/edit.js.erb +7 -0
- data/app/views/rails_db/tables/update.js.erb +3 -0
- data/config/routes.rb +2 -0
- data/lib/rails_db.rb +1 -0
- data/lib/rails_db/sql_import.rb +1 -1
- data/lib/rails_db/table.rb +11 -0
- data/lib/rails_db/version.rb +1 -1
- data/rails_db.gemspec +2 -0
- data/test/dashboard_controller_test.rb +11 -2
- data/test/dummy/db/migrate/20151121125538_add_boolean_field_to_user.rb +5 -0
- 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 +44 -43
- data/test/dummy/tmp/pids/server.pid +1 -0
- data/test/standalone/Gemfile +1 -0
- data/test/table_test.rb +9 -1
- metadata +25 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d99c898bfd1dfb091a63643e4340379cae66340d
|
4
|
+
data.tar.gz: face242fcca9d97b3a6a771cea8cba9e9f0c1c61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff10955cb11ef2746442969ff36b008a90aa4b8399e715a5d162fc52068e9edc10f69fc34184335acd60f3c477617798fcc875ab78c60bfc75705d565f7b66d7
|
7
|
+
data.tar.gz: 830e38745d4512024b766dca431fbcfd72b6813e5f11708a337381a0baab339558a07ef9d3f633846a5fe7ec269dcce89fe0d5b24e0002cf6da61c8ed177d6f1
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rails_db (0.
|
4
|
+
rails_db (0.9)
|
5
5
|
axlsx_rails
|
6
6
|
codemirror-rails
|
7
7
|
font-awesome-rails
|
@@ -10,6 +10,7 @@ PATH
|
|
10
10
|
rails (>= 3.1.0)
|
11
11
|
sass
|
12
12
|
sass-rails
|
13
|
+
simple_form
|
13
14
|
terminal-table
|
14
15
|
|
15
16
|
GEM
|
@@ -124,6 +125,9 @@ GEM
|
|
124
125
|
sprockets (>= 2.8, < 4.0)
|
125
126
|
sprockets-rails (>= 2.0, < 4.0)
|
126
127
|
tilt (>= 1.1, < 3)
|
128
|
+
simple_form (3.2.0)
|
129
|
+
actionpack (~> 4.0)
|
130
|
+
activemodel (~> 4.0)
|
127
131
|
sprockets (3.4.0)
|
128
132
|
rack (> 1, < 3)
|
129
133
|
sprockets-rails (2.3.3)
|
@@ -155,6 +159,7 @@ DEPENDENCIES
|
|
155
159
|
rails_db!
|
156
160
|
sass
|
157
161
|
sass-rails
|
162
|
+
simple_form
|
158
163
|
sqlite3
|
159
164
|
terminal-table
|
160
165
|
uglifier
|
@@ -1,5 +1,6 @@
|
|
1
1
|
//= require jquery
|
2
2
|
//= require jquery_ujs
|
3
|
+
//= require rails_db/foundation.min
|
3
4
|
//= require rails_db/foundation/foundation.abide
|
4
5
|
//= require rails_db/foundation/foundation.accordion
|
5
6
|
//= require rails_db/foundation/foundation.alert
|
@@ -8,7 +9,6 @@
|
|
8
9
|
//= require rails_db/foundation/foundation.equalizer
|
9
10
|
//= require rails_db/foundation/foundation.interchange
|
10
11
|
//= require rails_db/foundation/foundation.joyride
|
11
|
-
//= require rails_db/foundation.min
|
12
12
|
//= require rails_db/foundation/foundation.magellan
|
13
13
|
//= require rails_db/foundation/foundation.offcanvas
|
14
14
|
//= require rails_db/foundation/foundation.orbit
|
@@ -1,22 +1,23 @@
|
|
1
1
|
module RailsDb
|
2
2
|
class SqlController < RailsDb::ApplicationController
|
3
|
+
if Rails::VERSION::MAJOR >= 4
|
4
|
+
before_action :load_query, only: [:index, :execute, :csv, :xls]
|
5
|
+
else
|
6
|
+
before_filter :load_query
|
7
|
+
end
|
3
8
|
|
4
9
|
def index
|
5
|
-
load_query
|
6
10
|
end
|
7
11
|
|
8
12
|
def execute
|
9
|
-
load_query
|
10
13
|
render :index
|
11
14
|
end
|
12
15
|
|
13
16
|
def csv
|
14
|
-
load_query
|
15
17
|
send_data(@sql_query.to_csv, type: 'text/csv; charset=utf-8; header=present', filename: 'results.csv')
|
16
18
|
end
|
17
19
|
|
18
20
|
def xls
|
19
|
-
load_query
|
20
21
|
render xlsx: 'xls', filename: 'results.xlsx'
|
21
22
|
end
|
22
23
|
|
@@ -34,11 +35,10 @@ module RailsDb
|
|
34
35
|
render :import
|
35
36
|
end
|
36
37
|
|
37
|
-
|
38
38
|
private
|
39
39
|
|
40
40
|
def load_query
|
41
|
-
@sql
|
41
|
+
@sql = "#{params[:sql]}".strip
|
42
42
|
@sql_query = RailsDb::SqlQuery.new(@sql).execute
|
43
43
|
end
|
44
44
|
|
@@ -1,39 +1,44 @@
|
|
1
1
|
module RailsDb
|
2
2
|
class TablesController < RailsDb::ApplicationController
|
3
|
+
if Rails::VERSION::MAJOR >= 4
|
4
|
+
before_action :find_table, only: [:show, :data, :csv, :truncate, :destroy, :edit, :update, :xlsx]
|
5
|
+
else
|
6
|
+
before_filter :find_table
|
7
|
+
end
|
3
8
|
|
4
9
|
def index
|
5
10
|
@tables = RailsDb::Database.accessible_tables
|
6
11
|
end
|
7
12
|
|
8
13
|
def show
|
9
|
-
@table = RailsDb::Table.new(params[:id])
|
10
14
|
end
|
11
15
|
|
12
16
|
def data
|
13
|
-
per_page = params[:per_page] || session[:per_page]
|
14
17
|
session[:per_page] = per_page
|
15
|
-
@table
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
@table = @table.paginate page: params[:page],
|
19
|
+
sort_column: params[:sort_column],
|
20
|
+
sort_order: params[:sort_order],
|
21
|
+
per_page: per_page
|
19
22
|
end
|
20
23
|
|
21
24
|
def csv
|
22
|
-
@table = RailsDb::Table.new(params[:table_id])
|
23
25
|
send_data(@table.to_csv, type: 'text/csv; charset=utf-8; header=present', filename: "#{@table.name}.csv")
|
24
26
|
end
|
25
27
|
|
28
|
+
def xlsx
|
29
|
+
render xlsx: 'table', filename: "#{@table.name}.xlsx"
|
30
|
+
end
|
31
|
+
|
26
32
|
def truncate
|
27
|
-
@table = RailsDb::Table.new(params[:table_id])
|
28
33
|
@table.truncate
|
29
34
|
render :data
|
30
35
|
end
|
31
36
|
|
32
37
|
def destroy
|
33
|
-
@table =
|
34
|
-
|
35
|
-
|
36
|
-
|
38
|
+
@table = @table.paginate page: params[:page],
|
39
|
+
sort_column: params[:sort_column],
|
40
|
+
sort_order: params[:sort_order],
|
41
|
+
per_page: per_page
|
37
42
|
@table.delete(params[:pk_id])
|
38
43
|
respond_to do |page|
|
39
44
|
page.html { redirect_to action: :data, table_id: params[:table_id] }
|
@@ -41,9 +46,39 @@ module RailsDb
|
|
41
46
|
end
|
42
47
|
end
|
43
48
|
|
44
|
-
def
|
45
|
-
@
|
46
|
-
|
49
|
+
def edit
|
50
|
+
@record = @table.as_model.find(params[:pk_id])
|
51
|
+
respond_to do |page|
|
52
|
+
page.html { redirect_to action: :data, table_id: params[:table_id] }
|
53
|
+
page.js {}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def update
|
58
|
+
@record = @table.as_model.find(params[:pk_id])
|
59
|
+
@record.update_attributes(record_attributes)
|
60
|
+
respond_to do |page|
|
61
|
+
page.html { redirect_to action: :data, table_id: params[:table_id] }
|
62
|
+
page.js {}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def record_attributes
|
69
|
+
if Rails::VERSION::MAJOR >= 4
|
70
|
+
params[:record].permit!
|
71
|
+
else
|
72
|
+
params[:record]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def find_table
|
77
|
+
@table ||= RailsDb::Table.new(params[:id] || params[:table_id])
|
78
|
+
end
|
79
|
+
|
80
|
+
def per_page
|
81
|
+
params[:per_page] || session[:per_page]
|
47
82
|
end
|
48
83
|
|
49
84
|
end
|
@@ -8,6 +8,7 @@
|
|
8
8
|
<ul>
|
9
9
|
<li>use command line tools `railsdb` and `runsql` to run app and sql for your apps.</li>
|
10
10
|
<li>view content and schema of DB tables (including indexes)</li>
|
11
|
+
<li>edit content</li>
|
11
12
|
<li>sort content of DB tables</li>
|
12
13
|
<li>execute SQL queries</li>
|
13
14
|
<li>enjoy autocomplete for your SQL queries</li>
|
@@ -47,6 +47,7 @@
|
|
47
47
|
<tr>
|
48
48
|
<% if @table.primary_key.present? %>
|
49
49
|
<th class='delete_td'></th>
|
50
|
+
<th class='edit_td'></th>
|
50
51
|
<% end %>
|
51
52
|
<% @table.columns.each do |column| %>
|
52
53
|
<th class="column_<%= column.name %>" style=<%= display_style_column(@table.name, column.name) %>>
|
@@ -60,19 +61,8 @@
|
|
60
61
|
|
61
62
|
<tbody>
|
62
63
|
<% @table.data.each do |record| %>
|
63
|
-
<tr>
|
64
|
-
|
65
|
-
<td>
|
66
|
-
<%= link_to fa_icon('minus-circle'), delete_row_path(@table, record), :class => 'red', remote: true, title: 'Delete Record', confirm: 'Are you sure you want to delete this record?', data: {confirm: 'Are you sure you want to delete this record?'} %>
|
67
|
-
</td>
|
68
|
-
<% end %>
|
69
|
-
|
70
|
-
<% @table.columns.each do |column| %>
|
71
|
-
<td class="column_<%= column.name %>" style=<%= display_style_column(@table.name, column.name) %>>
|
72
|
-
<% name = column.name %>
|
73
|
-
<%= format_value(column, record[name]) %>
|
74
|
-
</td>
|
75
|
-
<% end %>
|
64
|
+
<tr class="row_<%= record[@table.primary_key] %>">
|
65
|
+
<%= render 'row', record: record %>
|
76
66
|
</tr>
|
77
67
|
<% end %>
|
78
68
|
<% n += 1 %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<a class="close-reveal-modal" aria-label="Close">×</a>
|
2
|
+
|
3
|
+
<h2 id="modalTitle">Edit</h2>
|
4
|
+
|
5
|
+
<%= simple_form_for @record, as: 'record', url: table_update_path(@table, pk_id: @record[@table.primary_key]), remote: true, method: :put, html: {class: 'vertical_form'} do |form| %>
|
6
|
+
<div class='scrollable_form'>
|
7
|
+
<% @record.class.columns.each do |column| %>
|
8
|
+
<% name = column.name %>
|
9
|
+
<% next if name == 'id' %>
|
10
|
+
|
11
|
+
<% if ['datetime', 'date', 'time'].include?(column.sql_type) %>
|
12
|
+
<div class='form-inline'>
|
13
|
+
<%= form.input name, label: name, input_html: {class: 'date_or_time'} %>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<% else %>
|
17
|
+
<%= form.input name, label: name %>
|
18
|
+
<% end %>
|
19
|
+
<% end %>
|
20
|
+
</div>
|
21
|
+
<%= form.submit 'SAVE', class: 'button small' %>
|
22
|
+
<a class='close' onclick="$('#system_modal').foundation('reveal', 'close');$">Close</a>
|
23
|
+
<% end %>
|
24
|
+
|
25
|
+
<span class="radius warning label">NOTE: Update will happen without any validations.</span>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% if @table.primary_key.present? %>
|
2
|
+
<td>
|
3
|
+
<%= link_to fa_icon('minus-circle'), delete_row_path(@table, record), :class => 'red', remote: true, title: 'Delete Record', confirm: 'Are you sure you want to delete this record?', data: {confirm: 'Are you sure you want to delete this record?'} %>
|
4
|
+
</td>
|
5
|
+
<td>
|
6
|
+
<%= link_to fa_icon('pencil-square'), table_edit_path(@table, pk_id: record[@table.primary_key]), :class => 'yellow', remote: true, title: 'Edit Record' %>
|
7
|
+
</td>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% @table.columns.each do |column| %>
|
11
|
+
<td class="column_<%= column.name %>" style=<%= display_style_column(@table.name, column.name) %>>
|
12
|
+
<% name = column.name %>
|
13
|
+
<%= format_value(column, record[name]) %>
|
14
|
+
</td>
|
15
|
+
<% end %>
|
data/config/routes.rb
CHANGED
data/lib/rails_db.rb
CHANGED
data/lib/rails_db/sql_import.rb
CHANGED
data/lib/rails_db/table.rb
CHANGED
@@ -16,6 +16,7 @@ module RailsDb
|
|
16
16
|
throw 'Access Denied' unless RailsDb::Database.accessible_tables.include?(table_name)
|
17
17
|
@name = table_name
|
18
18
|
@data = RailsDb::TableData.new(self)
|
19
|
+
self
|
19
20
|
end
|
20
21
|
|
21
22
|
def to_csv
|
@@ -43,6 +44,16 @@ module RailsDb
|
|
43
44
|
RailsDb::Database.delete(name, primary_key, id)
|
44
45
|
end
|
45
46
|
|
47
|
+
def create_model(table_name, &block)
|
48
|
+
klass = Class.new(ActiveRecord::Base) {self.table_name = table_name}
|
49
|
+
klass.class_eval(&block) if block_given?
|
50
|
+
klass
|
51
|
+
end
|
52
|
+
|
53
|
+
def as_model
|
54
|
+
@model ||= create_model(name)
|
55
|
+
end
|
56
|
+
|
46
57
|
end # module
|
47
58
|
|
48
59
|
end
|
data/lib/rails_db/version.rb
CHANGED
data/rails_db.gemspec
CHANGED
@@ -26,10 +26,12 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_dependency 'launchy'
|
27
27
|
s.add_dependency 'terminal-table'
|
28
28
|
s.add_dependency 'axlsx_rails'
|
29
|
+
s.add_dependency 'simple_form'
|
29
30
|
|
30
31
|
s.add_development_dependency "sqlite3"
|
31
32
|
s.add_development_dependency "mysql2", '<= 0.3.20'
|
32
33
|
s.add_development_dependency "pg"
|
33
34
|
# s.add_development_dependency 'populator'
|
34
35
|
# s.add_development_dependency 'faker'
|
36
|
+
# s.add_development_dependency 'pry'
|
35
37
|
end
|
@@ -7,6 +7,7 @@ class DashboardControllerTest < ActionDispatch::IntegrationTest
|
|
7
7
|
Account.delete_all
|
8
8
|
|
9
9
|
user = User.create(name: 'Igor')
|
10
|
+
edit_user = User.create(name: 'Edit')
|
10
11
|
account = Account.create(name: 'Igor')
|
11
12
|
|
12
13
|
get '/rails/db'
|
@@ -38,10 +39,10 @@ class DashboardControllerTest < ActionDispatch::IntegrationTest
|
|
38
39
|
get '/rails/db/tables/users/data?sort_column=id&sort_order=desc'
|
39
40
|
assert_equal 200, status
|
40
41
|
|
41
|
-
assert_equal
|
42
|
+
assert_equal 2, User.count
|
42
43
|
get "/rails/db/tables/users/destroy?pk_id=#{user.id}"
|
43
44
|
assert_equal 302, status
|
44
|
-
assert_equal
|
45
|
+
assert_equal 1, User.count
|
45
46
|
|
46
47
|
get '/rails/db/tables/users/csv'
|
47
48
|
assert_equal 200, status
|
@@ -60,6 +61,14 @@ class DashboardControllerTest < ActionDispatch::IntegrationTest
|
|
60
61
|
|
61
62
|
post '/rails/db/sql-xls.xls?sql=select+%2A+from+users+limit+10'
|
62
63
|
assert_equal 200, status
|
64
|
+
|
65
|
+
xhr :get, '/rails/db/tables/users/edit?pk_id=' + edit_user.id.to_s
|
66
|
+
assert_equal 200, status
|
67
|
+
|
68
|
+
xhr :put, '/rails/db/tables/users/update?pk_id=' + edit_user.id.to_s, {record: { name: 'JOHN' }}
|
69
|
+
assert_equal 200, status
|
70
|
+
edit_user.reload
|
71
|
+
assert_equal 'JOHN', edit_user.name
|
63
72
|
end
|
64
73
|
|
65
74
|
end
|
Binary file
|
Binary file
|
data/test/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20151121125538) do
|
15
15
|
|
16
16
|
create_table "accounts", force: :cascade do |t|
|
17
17
|
t.string "name"
|
@@ -52,46 +52,46 @@ ActiveRecord::Schema.define(version: 20151028191429) do
|
|
52
52
|
|
53
53
|
create_table "projects", force: :cascade do |t|
|
54
54
|
t.string "name"
|
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 "
|
55
|
+
t.string "description_880941"
|
56
|
+
t.string "description_609312"
|
57
|
+
t.string "description_45120"
|
58
|
+
t.string "description_646956"
|
59
|
+
t.string "description_359190"
|
60
|
+
t.string "description_414526"
|
61
|
+
t.string "description_126104"
|
62
|
+
t.string "description_21394"
|
63
|
+
t.string "description_200553"
|
64
|
+
t.string "description_47383"
|
65
|
+
t.string "description_817819"
|
66
|
+
t.string "description_297200"
|
67
|
+
t.string "description_732496"
|
68
|
+
t.string "description_578733"
|
69
|
+
t.string "description_181448"
|
70
|
+
t.string "description_591849"
|
71
|
+
t.string "description_29523"
|
72
|
+
t.string "description_859516"
|
73
|
+
t.string "description_607626"
|
74
|
+
t.string "description_634417"
|
75
|
+
t.integer "amount_96786"
|
76
|
+
t.integer "amount_118208"
|
77
|
+
t.integer "amount_354589"
|
78
|
+
t.integer "amount_529364"
|
79
|
+
t.integer "amount_2748"
|
80
|
+
t.integer "amount_265448"
|
81
|
+
t.integer "amount_87259"
|
82
|
+
t.integer "amount_69192"
|
83
|
+
t.integer "amount_400320"
|
84
|
+
t.integer "amount_981344"
|
85
|
+
t.integer "amount_724725"
|
86
|
+
t.integer "amount_233529"
|
87
|
+
t.integer "amount_10548"
|
88
|
+
t.integer "amount_918245"
|
89
|
+
t.integer "amount_400389"
|
90
|
+
t.integer "amount_630390"
|
91
|
+
t.integer "amount_183655"
|
92
|
+
t.integer "amount_83287"
|
93
|
+
t.integer "amount_252578"
|
94
|
+
t.integer "amount_147921"
|
95
95
|
t.datetime "created_at", null: false
|
96
96
|
t.datetime "updated_at", null: false
|
97
97
|
end
|
@@ -109,10 +109,11 @@ ActiveRecord::Schema.define(version: 20151028191429) do
|
|
109
109
|
t.integer "age"
|
110
110
|
t.decimal "salary"
|
111
111
|
t.text "bio"
|
112
|
-
t.datetime "created_at",
|
113
|
-
t.datetime "updated_at",
|
112
|
+
t.datetime "created_at", null: false
|
113
|
+
t.datetime "updated_at", null: false
|
114
114
|
t.integer "account_id"
|
115
115
|
t.date "dob"
|
116
|
+
t.boolean "active", default: true
|
116
117
|
end
|
117
118
|
|
118
119
|
add_index "users", ["account_id"], name: "index_users_on_account_id"
|
@@ -0,0 +1 @@
|
|
1
|
+
62164
|
data/test/standalone/Gemfile
CHANGED
data/test/table_test.rb
CHANGED
@@ -8,7 +8,7 @@ class TableTest < ActiveSupport::TestCase
|
|
8
8
|
end
|
9
9
|
|
10
10
|
test 'columns' do
|
11
|
-
assert_equal @users_table.column_names, ["id", "name", "age", "salary", "bio", "created_at", "updated_at", "account_id", "dob"]
|
11
|
+
assert_equal @users_table.column_names, ["id", "name", "age", "salary", "bio", "created_at", "updated_at", "account_id", "dob", "active"]
|
12
12
|
end
|
13
13
|
|
14
14
|
test 'to_csv' do
|
@@ -41,4 +41,12 @@ class TableTest < ActiveSupport::TestCase
|
|
41
41
|
assert_equal 1, User.where(name: 'john').count
|
42
42
|
end
|
43
43
|
|
44
|
+
test 'as_table' do
|
45
|
+
User.delete_all
|
46
|
+
user_1 = User.create(name: 'igor')
|
47
|
+
|
48
|
+
klass = @users_table.as_model
|
49
|
+
assert_equal 'igor', klass.first.name
|
50
|
+
end
|
51
|
+
|
44
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_db
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.9'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kasyanchuk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simple_form
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: sqlite3
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,6 +244,7 @@ files:
|
|
230
244
|
- app/assets/javascripts/rails_db/vendor/placeholder.js
|
231
245
|
- app/assets/stylesheets/rails_db/app.css.scss
|
232
246
|
- app/assets/stylesheets/rails_db/application.css
|
247
|
+
- app/assets/stylesheets/rails_db/forms.css.scss
|
233
248
|
- app/assets/stylesheets/rails_db/foundation.css
|
234
249
|
- app/assets/stylesheets/rails_db/foundation.min.css
|
235
250
|
- app/assets/stylesheets/rails_db/foundation_and_overrides.css.scss
|
@@ -264,14 +279,18 @@ files:
|
|
264
279
|
- app/views/rails_db/sql/index.html.erb
|
265
280
|
- app/views/rails_db/sql/xls.xls.axlsx
|
266
281
|
- app/views/rails_db/tables/_data.html.erb
|
282
|
+
- app/views/rails_db/tables/_edit.html.erb
|
283
|
+
- app/views/rails_db/tables/_row.html.erb
|
267
284
|
- app/views/rails_db/tables/_show.html.erb
|
268
285
|
- app/views/rails_db/tables/data.html.erb
|
269
286
|
- app/views/rails_db/tables/data.js.erb
|
270
287
|
- app/views/rails_db/tables/destroy.js.erb
|
288
|
+
- app/views/rails_db/tables/edit.js.erb
|
271
289
|
- app/views/rails_db/tables/index.html.erb
|
272
290
|
- app/views/rails_db/tables/show.html.erb
|
273
291
|
- app/views/rails_db/tables/show.js.erb
|
274
292
|
- app/views/rails_db/tables/table.xls.axlsx
|
293
|
+
- app/views/rails_db/tables/update.js.erb
|
275
294
|
- bin/rails_db
|
276
295
|
- bin/railsdb
|
277
296
|
- bin/runsql
|
@@ -371,6 +390,7 @@ files:
|
|
371
390
|
- test/dummy/db/migrate/20151027192250_create_payments.rb
|
372
391
|
- test/dummy/db/migrate/20151027223149_add_non_pk_table.rb
|
373
392
|
- test/dummy/db/migrate/20151028191429_create_legacy_accounts.rb
|
393
|
+
- test/dummy/db/migrate/20151121125538_add_boolean_field_to_user.rb
|
374
394
|
- test/dummy/db/rails_db.sqlite3
|
375
395
|
- test/dummy/db/rails_db_dev.sqlite3
|
376
396
|
- test/dummy/db/schema.rb
|
@@ -391,6 +411,7 @@ files:
|
|
391
411
|
- test/dummy/test/models/legacy_account_test.rb
|
392
412
|
- test/dummy/test/models/project_test.rb
|
393
413
|
- test/dummy/test/models/user_test.rb
|
414
|
+
- test/dummy/tmp/pids/server.pid
|
394
415
|
- test/rails_db_data_table_helper_test.rb
|
395
416
|
- test/rails_db_test.rb
|
396
417
|
- test/sql_import_test.rb
|
@@ -535,6 +556,7 @@ test_files:
|
|
535
556
|
- test/dummy/db/migrate/20151027192250_create_payments.rb
|
536
557
|
- test/dummy/db/migrate/20151027223149_add_non_pk_table.rb
|
537
558
|
- test/dummy/db/migrate/20151028191429_create_legacy_accounts.rb
|
559
|
+
- test/dummy/db/migrate/20151121125538_add_boolean_field_to_user.rb
|
538
560
|
- test/dummy/db/rails_db.sqlite3
|
539
561
|
- test/dummy/db/rails_db_dev.sqlite3
|
540
562
|
- test/dummy/db/schema.rb
|
@@ -557,6 +579,7 @@ test_files:
|
|
557
579
|
- test/dummy/test/models/legacy_account_test.rb
|
558
580
|
- test/dummy/test/models/project_test.rb
|
559
581
|
- test/dummy/test/models/user_test.rb
|
582
|
+
- test/dummy/tmp/pids/server.pid
|
560
583
|
- test/rails_db_data_table_helper_test.rb
|
561
584
|
- test/rails_db_test.rb
|
562
585
|
- test/sql_import_test.rb
|