gdonald-railsdb 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +674 -0
- data/README.txt +40 -0
- data/README_RAILS.txt +204 -0
- data/Rakefile +31 -0
- data/app/controllers/application.rb +24 -0
- data/app/controllers/database_controller.rb +274 -0
- data/app/controllers/home_controller.rb +366 -0
- data/app/helpers/application_helper.rb +43 -0
- data/app/helpers/home_helper.rb +2 -0
- data/app/models/database.rb +113 -0
- data/app/models/driver.rb +8 -0
- data/app/models/field.rb +117 -0
- data/app/models/group.rb +12 -0
- data/app/models/group_permission.rb +6 -0
- data/app/models/permission.rb +9 -0
- data/app/models/row.rb +26 -0
- data/app/models/switch.rb +85 -0
- data/app/models/table.rb +155 -0
- data/app/models/user.rb +98 -0
- data/app/models/user_group.rb +6 -0
- data/app/views/database/_field.html.erb +20 -0
- data/app/views/database/_field_form.html.erb +28 -0
- data/app/views/database/_insert_form.html.erb +37 -0
- data/app/views/database/_new_field.html.erb +43 -0
- data/app/views/database/_new_field_header.html.erb +12 -0
- data/app/views/database/_pagination.html.erb +14 -0
- data/app/views/database/_row.html.erb +16 -0
- data/app/views/database/_table.html.erb +22 -0
- data/app/views/database/_table_form.html.erb +45 -0
- data/app/views/database/add_fields.html.erb +3 -0
- data/app/views/database/add_table.html.erb +3 -0
- data/app/views/database/blank_field.rjs +6 -0
- data/app/views/database/browse.html.erb +30 -0
- data/app/views/database/del_field.html.erb +31 -0
- data/app/views/database/del_table.html.erb +31 -0
- data/app/views/database/edit_field.html.erb +23 -0
- data/app/views/database/edit_row.html.erb +22 -0
- data/app/views/database/index.html.erb +23 -0
- data/app/views/database/insert.html.erb +3 -0
- data/app/views/database/table.html.erb +30 -0
- data/app/views/home/_database.html.erb +8 -0
- data/app/views/home/_database_form.html.erb +68 -0
- data/app/views/home/_driver.html.erb +5 -0
- data/app/views/home/_driver_form.html.erb +25 -0
- data/app/views/home/_group.html.erb +10 -0
- data/app/views/home/_group_form.html.erb +25 -0
- data/app/views/home/_group_permission.html.erb +4 -0
- data/app/views/home/_permission.html.erb +6 -0
- data/app/views/home/_permission_form.html.erb +32 -0
- data/app/views/home/_user.html.erb +10 -0
- data/app/views/home/_user_form.html.erb +64 -0
- data/app/views/home/_user_group.html.erb +4 -0
- data/app/views/home/add_database.html.erb +3 -0
- data/app/views/home/add_driver.html.erb +3 -0
- data/app/views/home/add_group.html.erb +4 -0
- data/app/views/home/add_permission.html.erb +3 -0
- data/app/views/home/add_user.html.erb +62 -0
- data/app/views/home/bottom.html.erb +17 -0
- data/app/views/home/databases.html.erb +22 -0
- data/app/views/home/del_database.html.erb +31 -0
- data/app/views/home/del_driver.html.erb +32 -0
- data/app/views/home/del_group.html.erb +32 -0
- data/app/views/home/del_group_permission.html.erb +32 -0
- data/app/views/home/del_permission.html.erb +32 -0
- data/app/views/home/del_user.html.erb +33 -0
- data/app/views/home/del_user_group.html.erb +32 -0
- data/app/views/home/drivers.html.erb +20 -0
- data/app/views/home/edit_database.html.erb +3 -0
- data/app/views/home/edit_driver.html.erb +3 -0
- data/app/views/home/edit_group.html.erb +4 -0
- data/app/views/home/edit_permission.html.erb +4 -0
- data/app/views/home/edit_user.html.erb +84 -0
- data/app/views/home/group_permissions.html.erb +38 -0
- data/app/views/home/groups.html.erb +20 -0
- data/app/views/home/index.html.erb +21 -0
- data/app/views/home/login.html.erb +42 -0
- data/app/views/home/menu.html.erb +33 -0
- data/app/views/home/permissions.html.erb +21 -0
- data/app/views/home/top.html.erb +22 -0
- data/app/views/home/user_groups.html.erb +44 -0
- data/app/views/home/users.html.erb +27 -0
- data/app/views/layouts/application.html.erb +18 -0
- data/config/boot.rb +109 -0
- data/config/database.yml +14 -0
- data/config/environment.rb +114 -0
- data/config/environments/development.rb +18 -0
- data/config/environments/production.rb +19 -0
- data/config/environments/test.rb +22 -0
- data/config/initializers/inflections.rb +10 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/routes.rb +135 -0
- data/db/migrate/001_create_sessions.rb +17 -0
- data/db/migrate/002_create_users.rb +26 -0
- data/db/migrate/003_create_groups.rb +17 -0
- data/db/migrate/004_create_permissions.rb +18 -0
- data/db/migrate/005_create_group_permissions.rb +22 -0
- data/db/migrate/006_create_user_groups.rb +19 -0
- data/db/migrate/007_create_drivers.rb +17 -0
- data/db/migrate/008_create_databases.rb +43 -0
- data/db/schema.rb +91 -0
- data/lib/ignore +0 -0
- data/log/ignore +0 -0
- data/public/404.html +30 -0
- data/public/422.html +30 -0
- data/public/500.html +30 -0
- data/public/dispatch.cgi +10 -0
- data/public/dispatch.fcgi +24 -0
- data/public/dispatch.rb +10 -0
- data/public/favicon.ico +0 -0
- data/public/images/rails.png +0 -0
- data/public/images/ss1.png +0 -0
- data/public/images/ss2.png +0 -0
- data/public/images/ss3.png +0 -0
- data/public/images/ss4.png +0 -0
- data/public/images/ss5.png +0 -0
- data/public/images/ss6.png +0 -0
- data/public/javascripts/application.js +25 -0
- data/public/javascripts/controls.js +963 -0
- data/public/javascripts/dragdrop.js +972 -0
- data/public/javascripts/effects.js +1120 -0
- data/public/javascripts/prototype.js +4225 -0
- data/public/robots.txt +4 -0
- data/public/stylesheets/railsdb.css +227 -0
- data/script/about +3 -0
- data/script/console +3 -0
- data/script/destroy +3 -0
- data/script/generate +3 -0
- data/script/performance/benchmarker +3 -0
- data/script/performance/profiler +3 -0
- data/script/performance/request +3 -0
- data/script/plugin +3 -0
- data/script/process/inspector +3 -0
- data/script/process/reaper +3 -0
- data/script/process/spawner +3 -0
- data/script/runner +3 -0
- data/script/server +3 -0
- data/test/fixtures/databases.yml +7 -0
- data/test/fixtures/drivers.yml +7 -0
- data/test/fixtures/group_permissions.yml +7 -0
- data/test/fixtures/groups.yml +7 -0
- data/test/fixtures/permissions.yml +7 -0
- data/test/fixtures/user_groups.yml +7 -0
- data/test/fixtures/users.yml +18 -0
- data/test/functional/home_controller_test.rb +8 -0
- data/test/test_helper.rb +38 -0
- data/test/unit/database_test.rb +8 -0
- data/test/unit/driver_test.rb +8 -0
- data/test/unit/group_permission_test.rb +8 -0
- data/test/unit/group_test.rb +8 -0
- data/test/unit/permission_test.rb +8 -0
- data/test/unit/user_group_test.rb +8 -0
- data/test/unit/user_test.rb +9 -0
- data/tmp/pids/ignore +0 -0
- data/tmp/sessions/ignore +0 -0
- data/tmp/sockets/ignore +0 -0
- metadata +287 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title></title>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
+
<%= javascript_include_tag :defaults %>
|
8
|
+
<%= stylesheet_link_tag 'railsdb' %>
|
9
|
+
<base target="main" />
|
10
|
+
</head>
|
11
|
+
<body scroll="no" bgcolor="#808080">
|
12
|
+
<table id="menu">
|
13
|
+
<tr>
|
14
|
+
<td><%= link_to "Databases (#{ Database.count })", :controller => 'home', :action => 'databases' %></td>
|
15
|
+
</tr>
|
16
|
+
<tr>
|
17
|
+
<td><%= link_to "Drivers (#{ Driver.count })", :controller => 'home', :action => 'drivers' %></td>
|
18
|
+
</tr>
|
19
|
+
<tr>
|
20
|
+
<td><%= link_to "Users (#{ User.count })", :controller => 'home', :action => 'users' %></td>
|
21
|
+
</tr>
|
22
|
+
<tr>
|
23
|
+
<td><%= link_to "Groups (#{ Group.count })", :controller => 'home', :action => 'groups' %></td>
|
24
|
+
</tr>
|
25
|
+
<tr>
|
26
|
+
<td><%= link_to "Permissions (#{ Permission.count })", :controller => 'home', :action => 'permissions' %></td>
|
27
|
+
</tr>
|
28
|
+
<tr>
|
29
|
+
<td><%= link_to 'Logout', { :controller => 'home' , :action => 'logout' }, :target => '_top' %></td>
|
30
|
+
</tr>
|
31
|
+
</table>
|
32
|
+
</body>
|
33
|
+
</html>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<h2>Permissions</h2>
|
2
|
+
|
3
|
+
<table class="data">
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<td>Name</td>
|
7
|
+
<td>Description</td>
|
8
|
+
<td colspan="2" align="right"><%= link_to 'Add', { :controller => 'home', :action => 'add_permission' }, :class => 'add' %></td>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
<tbody>
|
12
|
+
<% if @permissions.size > 0 -%>
|
13
|
+
<%= render :partial => 'home/permission', :collection => @permissions %>
|
14
|
+
<% else -%>
|
15
|
+
<tr<%= alt %>>
|
16
|
+
<td colspan="4">No permissions found</td>
|
17
|
+
</tr>
|
18
|
+
<% end -%>
|
19
|
+
</tbody>
|
20
|
+
</table>
|
21
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title></title>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
+
<%= javascript_include_tag :defaults %>
|
8
|
+
<%= stylesheet_link_tag 'railsdb' %>
|
9
|
+
<base target="main" />
|
10
|
+
</head>
|
11
|
+
<body scroll="no" bgcolor="#cccccc">
|
12
|
+
<table id="top">
|
13
|
+
<tr>
|
14
|
+
<td class="t" rowspan="2"><%= SITE_TITLE %></td>
|
15
|
+
<td class="a">Administration Panel</td>
|
16
|
+
</tr>
|
17
|
+
<tr>
|
18
|
+
<td class="l"><%= h SITE_TITLE %>: <%= link_to 'Homepage', 'http://railsdb.org/', :target => '_blank' %> | <%= link_to 'Docs', 'http://railsdb.org/docs/', :target => '_blank' %> | <%= link_to 'License', 'http://railsdb.org/LICENSE.txt', :target => '_blank' %></td>
|
19
|
+
</tr>
|
20
|
+
</table>
|
21
|
+
</body>
|
22
|
+
</html>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<h2><%= link_to 'Users', :controller => 'home', :action => 'users' %> » <%= @user.lname %>, <%= @user.fname %> Groups</h2>
|
2
|
+
|
3
|
+
<table class="data">
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<td colspan="2">Group</td>
|
7
|
+
</tr>
|
8
|
+
</thead>
|
9
|
+
<tbody>
|
10
|
+
|
11
|
+
<% if @user_groups.size > 0 -%>
|
12
|
+
|
13
|
+
<%= render :partial => 'home/user_group', :collection => @user_groups %>
|
14
|
+
|
15
|
+
<% else -%>
|
16
|
+
|
17
|
+
<tr class="alt">
|
18
|
+
<td colspan="2">No user groups found</td>
|
19
|
+
</tr>
|
20
|
+
|
21
|
+
<% end -%>
|
22
|
+
|
23
|
+
</tbody>
|
24
|
+
</table>
|
25
|
+
|
26
|
+
<% form_tag :controller => 'home', :action => 'add_user_group' do -%>
|
27
|
+
<%= hidden_field_tag 'user_id', @user.id %>
|
28
|
+
|
29
|
+
<table class="form">
|
30
|
+
<thead>
|
31
|
+
<tr class="label">
|
32
|
+
<td colspan="2">Add Group</td>
|
33
|
+
</tr>
|
34
|
+
</thead>
|
35
|
+
<tbody>
|
36
|
+
<tr<%= alt %>>
|
37
|
+
<td><%= select_tag 'group_id', '<option value=""> </option>' + options_from_collection_for_select( @groups, 'id', 'name' ) %></td>
|
38
|
+
<td><%= submit_tag 'Add' %></td>
|
39
|
+
</tr>
|
40
|
+
</tbody>
|
41
|
+
</table>
|
42
|
+
|
43
|
+
<% end -%>
|
44
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<h2>Users</h2>
|
2
|
+
|
3
|
+
<table class="data">
|
4
|
+
<thead>
|
5
|
+
<tr>
|
6
|
+
<td>Name</td>
|
7
|
+
<td>Groups</td>
|
8
|
+
<td colspan="2" align="right"><%= link_to 'Add', { :controller => 'home', :action => 'add_user' }, :class => 'add' %></td>
|
9
|
+
</tr>
|
10
|
+
</thead>
|
11
|
+
<tbody>
|
12
|
+
|
13
|
+
<% if @users.size > 0 -%>
|
14
|
+
|
15
|
+
<%= render :partial => 'home/user', :collection => @users %>
|
16
|
+
|
17
|
+
<% else -%>
|
18
|
+
|
19
|
+
<tr class="alt">
|
20
|
+
<td colspan="4">No users found</td>
|
21
|
+
</tr>
|
22
|
+
|
23
|
+
<% end -%>
|
24
|
+
|
25
|
+
</tbody>
|
26
|
+
</table>
|
27
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title></title>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
7
|
+
<%= javascript_include_tag :defaults %>
|
8
|
+
<%= stylesheet_link_tag 'railsdb' %>
|
9
|
+
<base target="main" />
|
10
|
+
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<% if flash[:notice] -%>
|
14
|
+
<p class="error"><%= flash[:notice] %></p>
|
15
|
+
<% end -%>
|
16
|
+
<%= yield :layout %>
|
17
|
+
</body>
|
18
|
+
</html>
|
data/config/boot.rb
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# Don't change this file!
|
2
|
+
# Configure your app in config/environment.rb and config/environments/*.rb
|
3
|
+
|
4
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
class << self
|
8
|
+
def boot!
|
9
|
+
unless booted?
|
10
|
+
preinitialize
|
11
|
+
pick_boot.run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def booted?
|
16
|
+
defined? Rails::Initializer
|
17
|
+
end
|
18
|
+
|
19
|
+
def pick_boot
|
20
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
21
|
+
end
|
22
|
+
|
23
|
+
def vendor_rails?
|
24
|
+
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
25
|
+
end
|
26
|
+
|
27
|
+
# FIXME : Ruby 1.9
|
28
|
+
def preinitialize
|
29
|
+
load(preinitializer_path) if File.exists?(preinitializer_path)
|
30
|
+
end
|
31
|
+
|
32
|
+
def preinitializer_path
|
33
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Boot
|
38
|
+
def run
|
39
|
+
load_initializer
|
40
|
+
Rails::Initializer.run(:set_load_path)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class VendorBoot < Boot
|
45
|
+
def load_initializer
|
46
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class GemBoot < Boot
|
51
|
+
def load_initializer
|
52
|
+
self.class.load_rubygems
|
53
|
+
load_rails_gem
|
54
|
+
require 'initializer'
|
55
|
+
end
|
56
|
+
|
57
|
+
def load_rails_gem
|
58
|
+
if version = self.class.gem_version
|
59
|
+
gem 'rails', version
|
60
|
+
else
|
61
|
+
gem 'rails'
|
62
|
+
end
|
63
|
+
rescue Gem::LoadError => load_error
|
64
|
+
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
class << self
|
69
|
+
def rubygems_version
|
70
|
+
Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
|
71
|
+
end
|
72
|
+
|
73
|
+
def gem_version
|
74
|
+
if defined? RAILS_GEM_VERSION
|
75
|
+
RAILS_GEM_VERSION
|
76
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
77
|
+
ENV['RAILS_GEM_VERSION']
|
78
|
+
else
|
79
|
+
parse_gem_version(read_environment_rb)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def load_rubygems
|
84
|
+
require 'rubygems'
|
85
|
+
|
86
|
+
unless rubygems_version >= '0.9.4'
|
87
|
+
$stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
88
|
+
exit 1
|
89
|
+
end
|
90
|
+
|
91
|
+
rescue LoadError
|
92
|
+
$stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
93
|
+
exit 1
|
94
|
+
end
|
95
|
+
|
96
|
+
def parse_gem_version(text)
|
97
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
def read_environment_rb
|
102
|
+
File.read("#{RAILS_ROOT}/config/environment.rb")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# All that for this:
|
109
|
+
Rails.boot!
|
data/config/database.yml
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file
|
2
|
+
|
3
|
+
# Uncomment below to force Rails into production mode when
|
4
|
+
# you don't control web/app server and can't set it the proper way
|
5
|
+
# ENV['RAILS_ENV'] ||= 'production'
|
6
|
+
|
7
|
+
# Specifies gem version of Rails to use when vendor/rails is not present
|
8
|
+
RAILS_GEM_VERSION = '2.0.2' unless defined? RAILS_GEM_VERSION
|
9
|
+
|
10
|
+
# Bootstrap the Rails environment, frameworks, and default configuration
|
11
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
12
|
+
|
13
|
+
Rails::Initializer.run do |config|
|
14
|
+
# Settings in config/environments/* take precedence over those specified here.
|
15
|
+
# Application configuration should go into files in config/initializers
|
16
|
+
# -- all .rb files in that directory are automatically loaded.
|
17
|
+
# See Rails::Configuration for more options.
|
18
|
+
|
19
|
+
# Skip frameworks you're not going to use (only works if using vendor/rails).
|
20
|
+
# To use Rails without a database, you must remove the Active Record framework
|
21
|
+
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
|
22
|
+
|
23
|
+
# Only load the plugins named here, in the order given. By default, all plugins
|
24
|
+
# in vendor/plugins are loaded in alphabetical order.
|
25
|
+
# :all can be used as a placeholder for all plugins not explicitly named
|
26
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
27
|
+
|
28
|
+
# Add additional load paths for your own custom dirs
|
29
|
+
# config.load_paths += %W( #{RAILS_ROOT}/extras )
|
30
|
+
|
31
|
+
# Force all environments to use the same logger level
|
32
|
+
# (by default production uses :info, the others :debug)
|
33
|
+
# config.log_level = :debug
|
34
|
+
|
35
|
+
# Your secret key for verifying cookie session data integrity.
|
36
|
+
# If you change this key, all old sessions will become invalid!
|
37
|
+
# Make sure the secret is at least 30 characters and all random,
|
38
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
39
|
+
# config.action_controller.session = {
|
40
|
+
# :session_key => '_railsdb_session',
|
41
|
+
# :secret => '3e1169688926f48ca8731b64a1c3c2126a53404c1527cd97b7db1e87998f4f619b48461c9536a068ac218e6bdb8c551edccbd1c46f82db0b8d7a3f8cced8549c'
|
42
|
+
# }
|
43
|
+
|
44
|
+
# Use the database for sessions instead of the cookie-based default,
|
45
|
+
# which shouldn't be used to store highly confidential information
|
46
|
+
# (create the session table with 'rake db:sessions:create')
|
47
|
+
config.action_controller.session_store = :active_record_store
|
48
|
+
|
49
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
50
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
51
|
+
# like if you have constraints or database-specific column types
|
52
|
+
# config.active_record.schema_format = :sql
|
53
|
+
|
54
|
+
# Activate observers that should always be running
|
55
|
+
# config.active_record.observers = :cacher, :garbage_collector
|
56
|
+
|
57
|
+
# Make Active Record use UTC-base instead of local time
|
58
|
+
# config.active_record.default_timezone = :utc
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# TODO: Trademark this? Nah..
|
63
|
+
#
|
64
|
+
SITE_TITLE = 'RailsDB'
|
65
|
+
|
66
|
+
#
|
67
|
+
# How many rows per page
|
68
|
+
#
|
69
|
+
PER_PAGE = 20
|
70
|
+
|
71
|
+
#
|
72
|
+
# How many links to show on each side of current page
|
73
|
+
#
|
74
|
+
LINK_SPAN = 4
|
75
|
+
|
76
|
+
#
|
77
|
+
# Fixes for irregular pluralizations
|
78
|
+
#
|
79
|
+
Inflector.inflections.irregular 'database', 'databases'
|
80
|
+
|
81
|
+
#
|
82
|
+
# Dynamic table names can't override core Ruby/Rails classes
|
83
|
+
#
|
84
|
+
ALT_TABLE_NAMES = { 'proc' => 'proc_renamed', # mysql
|
85
|
+
'time_zone' => 'time_zone_renamed' # mysql
|
86
|
+
}
|
87
|
+
|
88
|
+
#
|
89
|
+
# Potential attributes of a field
|
90
|
+
#
|
91
|
+
FIELD_ATTRIBUTES = %w( name type null limit default scale precision )
|
92
|
+
|
93
|
+
#
|
94
|
+
# Table types, taken from:
|
95
|
+
# http://api.rubyonrails.com/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html#M001222
|
96
|
+
#
|
97
|
+
def get_field_types( driver )
|
98
|
+
field_types = %w( string text integer float decimal timestamp time date binary boolean primary_key )
|
99
|
+
%w( datetime ).each { |f| field_types << f } unless driver == 'postgresql'
|
100
|
+
field_types.sort
|
101
|
+
end
|
102
|
+
|
103
|
+
#
|
104
|
+
# Only include options that are actually present
|
105
|
+
#
|
106
|
+
def mangle_column_options( params, index )
|
107
|
+
opts = {}
|
108
|
+
opts[:null] = true if params[:fields][index][:null] == '1'
|
109
|
+
opts[:default] = params[:fields][index][:default] unless params[:fields][index][:default].empty?
|
110
|
+
opts[:limit] = params[:fields][index][:limit].to_i unless params[:fields][index][:limit].empty?
|
111
|
+
opts[:scale] = params[:fields][index][:scale].to_i unless params[:fields][index][:scale].empty?
|
112
|
+
opts[:precision] = params[:fields][index][:precision].to_i unless params[:fields][index][:precision].empty?
|
113
|
+
opts
|
114
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
2
|
+
|
3
|
+
# In the development environment your application's code is reloaded on
|
4
|
+
# every request. This slows down response time but is perfect for development
|
5
|
+
# since you don't have to restart the webserver when you make code changes.
|
6
|
+
config.cache_classes = false
|
7
|
+
|
8
|
+
# Log error messages when you accidentally call methods on nil.
|
9
|
+
config.whiny_nils = true
|
10
|
+
|
11
|
+
# Show full error reports and disable caching
|
12
|
+
config.action_controller.consider_all_requests_local = true
|
13
|
+
config.action_view.debug_rjs = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
config.action_view.cache_template_extensions = false
|
16
|
+
|
17
|
+
# Don't care if the mailer can't send
|
18
|
+
config.action_mailer.raise_delivery_errors = false
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
2
|
+
|
3
|
+
# The production environment is meant for finished, "live" apps.
|
4
|
+
# Code is not reloaded between requests
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Use a different logger for distributed setups
|
8
|
+
# config.logger = SyslogLogger.new
|
9
|
+
|
10
|
+
# Full error reports are disabled and caching is turned on
|
11
|
+
config.action_controller.consider_all_requests_local = false
|
12
|
+
config.action_controller.perform_caching = true
|
13
|
+
config.action_view.cache_template_loading = true
|
14
|
+
|
15
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
16
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
17
|
+
|
18
|
+
# Disable delivery errors, bad email addresses will be ignored
|
19
|
+
# config.action_mailer.raise_delivery_errors = false
|