real_fk 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +5 -0
- data/LICENSE +22 -0
- data/Manifest.txt +33 -0
- data/README +141 -0
- data/lib/real_fk.rb +83 -0
- data/test/rails_root/README +4 -0
- data/test/rails_root/app/controllers/application.rb +10 -0
- data/test/rails_root/app/models/conference.rb +3 -0
- data/test/rails_root/app/models/person.rb +4 -0
- data/test/rails_root/app/models/person_type.rb +3 -0
- data/test/rails_root/config/boot.rb +109 -0
- data/test/rails_root/config/database.yml +21 -0
- data/test/rails_root/config/environment.rb +13 -0
- data/test/rails_root/config/environments/mysql.rb +0 -0
- data/test/rails_root/config/environments/postgresql.rb +0 -0
- data/test/rails_root/config/environments/sqlite.rb +0 -0
- data/test/rails_root/config/environments/sqlite3.rb +0 -0
- data/test/rails_root/config/routes.rb +35 -0
- data/test/rails_root/db/migrate/001_create_people_conf.rb +36 -0
- data/test/rails_root/log/postgresql.log +403 -0
- data/test/rails_root/script/console +3 -0
- data/test/rails_root/vendor/plugins/real_fk/init.rb +2 -0
- data/test/test_helper.rb +27 -0
- data/test/unit/real_fk_test.rb +66 -0
- metadata +94 -0
data/CHANGELOG
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2008 Gunnar Wolf <gwolf@gwolf.org>
|
2
|
+
|
3
|
+
This is the MIT license, the license Ruby on Rails itself is licensed under.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
./Manifest.txt
|
2
|
+
./LICENSE
|
3
|
+
./init.rb
|
4
|
+
./lib/real_fk.rb
|
5
|
+
./doc/fr_class_index.html
|
6
|
+
./doc/index.html
|
7
|
+
./doc/files/README.html
|
8
|
+
./doc/files/lib/real_fk_rb.html
|
9
|
+
./doc/fr_file_index.html
|
10
|
+
./doc/fr_method_index.html
|
11
|
+
./doc/rdoc-style.css
|
12
|
+
./doc/created.rid
|
13
|
+
./README
|
14
|
+
./Rakefile
|
15
|
+
./test/rails_root/script/console
|
16
|
+
./test/rails_root/config/boot.rb
|
17
|
+
./test/rails_root/config/database.yml
|
18
|
+
./test/rails_root/config/environments/postgresql.rb
|
19
|
+
./test/rails_root/config/environments/sqlite3.rb
|
20
|
+
./test/rails_root/config/environments/mysql.rb
|
21
|
+
./test/rails_root/config/environments/sqlite.rb
|
22
|
+
./test/rails_root/config/routes.rb
|
23
|
+
./test/rails_root/config/environment.rb
|
24
|
+
./test/rails_root/README
|
25
|
+
./test/rails_root/db/migrate/001_create_people_conf.rb
|
26
|
+
./test/rails_root/vendor/plugins/real_fk/init.rb
|
27
|
+
./test/rails_root/app/models/person.rb
|
28
|
+
./test/rails_root/app/models/conference.rb
|
29
|
+
./test/rails_root/app/models/person_type.rb
|
30
|
+
./test/rails_root/app/controllers/application.rb
|
31
|
+
./test/test_helper.rb
|
32
|
+
./test/unit/real_fk_test.rb
|
33
|
+
./META.yml
|
data/README
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
= real_fk
|
2
|
+
|
3
|
+
This plugin extends the base <tt>Rails ActiveRecord::Migration</tt>
|
4
|
+
with some commonly used functionality, aiming at keeping your
|
5
|
+
migrations short, easy to understand and meaningful.
|
6
|
+
|
7
|
+
= Installing the plugin
|
8
|
+
|
9
|
+
The easiest way is through Rails' own +scripts/plugins+ utility. The
|
10
|
+
first thing you should do is to tell Rails where the plugin's tree is
|
11
|
+
located.
|
12
|
+
|
13
|
+
If you want to follow the latest changes, you will probably prefer
|
14
|
+
following the project's trunk, however, for production, I strongly
|
15
|
+
suggest you to stick to a stable release. Depending on what you
|
16
|
+
prefer, from your project's base directory, type:
|
17
|
+
|
18
|
+
$ ./script/plugin source http://realfk.rubyforge.org/svn/trunk/
|
19
|
+
|
20
|
+
Or, to follow a given release (say, 0.1 - Of course, check on the
|
21
|
+
latest stable release before doing this):
|
22
|
+
|
23
|
+
$ ./script/plugin source http://realfk.rubyforge.org/svn/tags/0.1/
|
24
|
+
|
25
|
+
Then, ask Rails to install the plugin:
|
26
|
+
|
27
|
+
$ ./script/plugin install real_fk
|
28
|
+
|
29
|
+
If you use Subversion for tracking your project's development, you
|
30
|
+
will probably want to mark the plugin as an <i>external</i>
|
31
|
+
repository. To do so, add the -x switch:
|
32
|
+
|
33
|
+
$ ./script/plugin install -x real_fk
|
34
|
+
|
35
|
+
= Using the plugin
|
36
|
+
|
37
|
+
== References
|
38
|
+
|
39
|
+
Rails is built upon a "dumb database" concept. Rails assumes the database
|
40
|
+
will not force restrictions upon the user - i.e. that the model validators
|
41
|
+
are all there is. But I disagree ;-)
|
42
|
+
|
43
|
+
So, if you want to create a relation field, properly acting as a foreign
|
44
|
+
key and refering to another table, instead of doing it via the
|
45
|
+
<tt>ActiveRecord::ConnectionAdapters::TableDefinition#column</tt> (or even
|
46
|
+
<tt>ActiveRecord::ConnectionAdapters::TableDefinition#references</tt>)
|
47
|
+
methods, declare them with +add_refrence+:
|
48
|
+
|
49
|
+
def self.up
|
50
|
+
create_table :proposals do |t|
|
51
|
+
(...)
|
52
|
+
end
|
53
|
+
create_table :proposal_types do |t|
|
54
|
+
(...)
|
55
|
+
end
|
56
|
+
create_table :proposal_statuses do |t|
|
57
|
+
(...)
|
58
|
+
end
|
59
|
+
add_reference :proposals, :proposal_types
|
60
|
+
add_reference :proposals, :proposal_statuses, :null => false, :default => 1
|
61
|
+
end
|
62
|
+
|
63
|
+
The corresponding fields (+proposal_type_id+ and +proposal_status_id+,
|
64
|
+
respectively) will be created in +proposals+, and the RDBMS will
|
65
|
+
impose a Foreign Key constraint.
|
66
|
+
|
67
|
+
The references can be removed via +remove_reference+, i.e., for inclusion in
|
68
|
+
+down+ migrations:
|
69
|
+
|
70
|
+
def self.down
|
71
|
+
remove_reference :proposals, :proposal_types
|
72
|
+
remove_reference :proposals, :proposal_statuses
|
73
|
+
drop_table :proposal_statuses
|
74
|
+
drop_table :proposal_types
|
75
|
+
drop_table :proposals
|
76
|
+
end
|
77
|
+
|
78
|
+
Of course, in this case the +remove_reference+ call is not really needed - But
|
79
|
+
if you are dropping a table that is referred to from a table that will
|
80
|
+
remain existing, you will have to remove the foreign key constraints (that
|
81
|
+
is, the referring columns).
|
82
|
+
|
83
|
+
== Join (HABTM) tables
|
84
|
+
|
85
|
+
When you define a simple +has_and_belongs_to_many+ (HABTM) relation in your
|
86
|
+
model, you are expected to create an extra table representing this relation.
|
87
|
+
This is a very simple table (i.e. it has only a row for each of the related
|
88
|
+
table's IDs), and it carries foreign key constraints (see the +References+
|
89
|
+
section).
|
90
|
+
|
91
|
+
Please note that join tables <i>are not supposed to carry any extra
|
92
|
+
columns</i> - If you need to add information to join tables, think twice and
|
93
|
+
better use a <tt>has_many :elements, :through => :othermodel</tt>
|
94
|
+
declaration, and create the +othermodel+ table manually.
|
95
|
+
|
96
|
+
To create a HABTM table representing that each person can attend many
|
97
|
+
conferences and each conference can be attended by many people:
|
98
|
+
|
99
|
+
def self.up
|
100
|
+
create_table :people do |t|
|
101
|
+
(...)
|
102
|
+
end
|
103
|
+
create_table :conferences do |t|
|
104
|
+
(...)
|
105
|
+
end
|
106
|
+
create_habtm :people, :conferences
|
107
|
+
end
|
108
|
+
def self.down
|
109
|
+
drop_habtm :people, :conferences
|
110
|
+
drop_table :people
|
111
|
+
drop_table :conferences
|
112
|
+
end
|
113
|
+
|
114
|
+
The last call will create a +conferences_people+ table (according to Rails'
|
115
|
+
conventions, table names are sorted alphabetically to get the join table's
|
116
|
+
name).
|
117
|
+
|
118
|
+
Note that in the +down+ migration, the +drop_habtm+ call <i>must appear
|
119
|
+
before</i> the +drop_table+ calls, as it carries foreign key constraints.
|
120
|
+
|
121
|
+
= Author
|
122
|
+
|
123
|
+
This plugin is Copyright (c) 2008 Gunnar Wolf <gwolf@gwolf.org>
|
124
|
+
|
125
|
+
== Licensing information
|
126
|
+
|
127
|
+
This plugin is under a MIT license. For further information, please
|
128
|
+
check the LICENSE file.
|
129
|
+
|
130
|
+
= Getting the code
|
131
|
+
|
132
|
+
The plugin project's home page can be found at
|
133
|
+
http://realfk.rubyforge.org/
|
134
|
+
|
135
|
+
The Rubyforge project page is http://rubyforge.org/projects/realfk/
|
136
|
+
|
137
|
+
The development branch of the SVN tree can be pulled anonymously from
|
138
|
+
http://realfk.rubyforge.org/svn/trunk/
|
139
|
+
|
140
|
+
Released versions can be found along the 'tags' directory of the SVN
|
141
|
+
tree, at http://realfk.rubyforge.org/svn/tags/
|
data/lib/real_fk.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
module GWolf #:nodoc:
|
2
|
+
module UNAM #:nodoc:
|
3
|
+
module RealFkMigrations #:nodoc:
|
4
|
+
|
5
|
+
def self.append_features(base)
|
6
|
+
super
|
7
|
+
|
8
|
+
# Adds a belongs_to relation from the first table to the second one, creating
|
9
|
+
# the foreign key, and creating the fields in the first table corresponding
|
10
|
+
# to what Rails expects them to be called.
|
11
|
+
#
|
12
|
+
# The received options will be passed on to the add_column call.
|
13
|
+
def add_reference(from, dest, options = {})
|
14
|
+
fieldname = fldname(dest)
|
15
|
+
|
16
|
+
add_column(from, fieldname, :integer, options)
|
17
|
+
add_constraint(from, dest)
|
18
|
+
end
|
19
|
+
|
20
|
+
def remove_reference(from, dest)
|
21
|
+
remove_column from, fldname(dest)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Creates a HABTM join-table between two given tables, so they can be
|
25
|
+
# linked with a has_and_belongs_to_many declaration in the model.
|
26
|
+
#
|
27
|
+
# Three indexes will be created for the table: A unique index, ensuring
|
28
|
+
# only one relation is created between any two given records, and two
|
29
|
+
# regular indexes, to ensure speedy lookups.
|
30
|
+
def create_habtm(first, second)
|
31
|
+
first, second = sort_tables(first, second)
|
32
|
+
first_fld = fldname(first)
|
33
|
+
second_fld = fldname(second)
|
34
|
+
join_tbl = "#{first}_#{second}"
|
35
|
+
|
36
|
+
# It is sad we cannot use our own tricks here, isn't it? :-/
|
37
|
+
# Some RDBMSs (notably, SQLite) won't allow for the creation of a
|
38
|
+
# table with no columns - So we create the table with a reference
|
39
|
+
# to the first table by hand... And just add cleanly the second
|
40
|
+
# table afterwards
|
41
|
+
create_table(join_tbl, :id => false) do |t|
|
42
|
+
t.integer fldname(first)
|
43
|
+
end
|
44
|
+
add_constraint join_tbl, first
|
45
|
+
add_reference join_tbl, second
|
46
|
+
|
47
|
+
add_index join_tbl, first_fld
|
48
|
+
add_index join_tbl, second_fld
|
49
|
+
add_index join_tbl, [first_fld, second_fld], :unique => true
|
50
|
+
end
|
51
|
+
|
52
|
+
# Drops a HABTM join-table between the two given tables.
|
53
|
+
def drop_habtm(first, second)
|
54
|
+
first, second = sort_tables(first, second)
|
55
|
+
drop_table "#{first}_#{second}"
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
def fldname(tbl) #:nodoc:
|
60
|
+
"#{tbl.to_s.singularize}_id"
|
61
|
+
end
|
62
|
+
|
63
|
+
def sort_tables(first, second) #:nodoc:
|
64
|
+
first, second = second, first if first.to_s > second.to_s
|
65
|
+
return first, second
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_constraint(from, to)
|
69
|
+
fld = fldname(to)
|
70
|
+
if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
|
71
|
+
execute "ALTER TABLE #{from} ADD CONSTRAINT " <<
|
72
|
+
"#{from}_#{fld}_fkey FOREIGN KEY (#{fld}) " <<
|
73
|
+
"REFERENCES #{to}(id) ON DELETE RESTRICT"
|
74
|
+
else
|
75
|
+
warn "Reference rquested from #{from} to #{to} - References " <<
|
76
|
+
"are not yet supported in " <<
|
77
|
+
ActiveRecord::Base.connection.adapter_name
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Filters added to this controller apply to all controllers in the application.
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
3
|
+
|
4
|
+
class ApplicationController < ActionController::Base
|
5
|
+
helper :all # include all helpers, all the time
|
6
|
+
|
7
|
+
# See ActionController::RequestForgeryProtection for details
|
8
|
+
# Uncomment the :secret if you're not using the cookie session store
|
9
|
+
protect_from_forgery # :secret => 'ec8a7a583ea1cce8b10146acadcad842'
|
10
|
+
end
|
@@ -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!
|
@@ -0,0 +1,21 @@
|
|
1
|
+
postgresql:
|
2
|
+
:adapter: postgresql
|
3
|
+
:username: gwolf
|
4
|
+
# :password: postgres
|
5
|
+
:database: real_fk_test
|
6
|
+
:min_messages: ERROR
|
7
|
+
# There is really not much point in testing this plugin with "lesser"
|
8
|
+
# RDBMS-like systems, such as SQLite or MySQL. It's not impossible, though...
|
9
|
+
#
|
10
|
+
# mysql:
|
11
|
+
# :adapter: mysql
|
12
|
+
# :host: localhost
|
13
|
+
# :username: root
|
14
|
+
# :password:
|
15
|
+
# :database: real_fk_test
|
16
|
+
# sqlite:
|
17
|
+
# :adapter: sqlite
|
18
|
+
# :dbfile: real_fk_test.sqlite.db
|
19
|
+
# sqlite3:
|
20
|
+
# :adapter: sqlite3
|
21
|
+
# :dbfile: real_fk_test.sqlite3.db
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Specifies gem version of Rails to use when vendor/rails is not present
|
2
|
+
#RAILS_GEM_VERSION = '2.0.2'
|
3
|
+
|
4
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
5
|
+
|
6
|
+
Rails::Initializer.run do |config|
|
7
|
+
config.log_level = :debug
|
8
|
+
config.cache_classes = false
|
9
|
+
config.whiny_nils = true
|
10
|
+
config.load_paths << "#{File.dirname(__FILE__)}/../../../lib/"
|
11
|
+
end
|
12
|
+
|
13
|
+
Dependencies.log_activity = true
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,35 @@
|
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
2
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
3
|
+
|
4
|
+
# Sample of regular route:
|
5
|
+
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
|
6
|
+
# Keep in mind you can assign values other than :controller and :action
|
7
|
+
|
8
|
+
# Sample of named route:
|
9
|
+
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
|
10
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
11
|
+
|
12
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
13
|
+
# map.resources :products
|
14
|
+
|
15
|
+
# Sample resource route with options:
|
16
|
+
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
|
17
|
+
|
18
|
+
# Sample resource route with sub-resources:
|
19
|
+
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
|
20
|
+
|
21
|
+
# Sample resource route within a namespace:
|
22
|
+
# map.namespace :admin do |admin|
|
23
|
+
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
|
24
|
+
# admin.resources :products
|
25
|
+
# end
|
26
|
+
|
27
|
+
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
|
28
|
+
# map.root :controller => "welcome"
|
29
|
+
|
30
|
+
# See how all your routes lay out with "rake routes"
|
31
|
+
|
32
|
+
# Install the default routes as the lowest priority.
|
33
|
+
map.connect ':controller/:action/:id'
|
34
|
+
map.connect ':controller/:action/:id.:format'
|
35
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class CreatePeopleConf < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :person_types, :force => true do |t|
|
4
|
+
t.column :name, :string
|
5
|
+
end
|
6
|
+
create_table :people, :force => true do |t|
|
7
|
+
t.column :name, :string
|
8
|
+
end
|
9
|
+
create_table :conferences, :force => true do |t|
|
10
|
+
t.column :name, :string
|
11
|
+
end
|
12
|
+
|
13
|
+
add_reference :people, :person_types, :null => false
|
14
|
+
create_habtm :people, :conferences
|
15
|
+
|
16
|
+
['Attendee', 'Organizer', 'Speaker'].map do |item|
|
17
|
+
PersonType.new(:name => item).save!
|
18
|
+
end
|
19
|
+
['Some Body', 'Some Buddy', 'Sum baddy'].map do |pers|
|
20
|
+
Person.new(:name => pers,
|
21
|
+
:person_type => PersonType.find(:all).rand).save!
|
22
|
+
end
|
23
|
+
['Boring', 'Interesting', 'Mediocre', 'Fun'].map do |conf|
|
24
|
+
Conference.new(:name => conf).save!
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.down
|
29
|
+
drop_habtm :people, :conferences
|
30
|
+
drop_reference :people, :person_types
|
31
|
+
|
32
|
+
drop_table :people
|
33
|
+
drop_table :conferences
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
@@ -0,0 +1,403 @@
|
|
1
|
+
# Logfile created on Tue Nov 25 12:15:40 -0600 2008Dependencies: called new_constants_in(Object)
|
2
|
+
Dependencies: called require_or_load("/home/gwolf/cvs/realfk/test/rails_root/app/controllers/application.rb", nil)
|
3
|
+
Dependencies: called new_constants_in(Object)
|
4
|
+
Dependencies: called new_constants_in(Object)
|
5
|
+
Dependencies: called new_constants_in(Object)
|
6
|
+
Dependencies: called new_constants_in(Object)
|
7
|
+
Dependencies: New constants:
|
8
|
+
Dependencies: called new_constants_in(Object)
|
9
|
+
Dependencies: New constants:
|
10
|
+
Dependencies: New constants:
|
11
|
+
Dependencies: called new_constants_in(Object)
|
12
|
+
Dependencies: New constants:
|
13
|
+
Dependencies: called new_constants_in(Object)
|
14
|
+
Dependencies: New constants:
|
15
|
+
Dependencies: called new_constants_in(Object)
|
16
|
+
Dependencies: New constants:
|
17
|
+
Dependencies: called new_constants_in(Object)
|
18
|
+
Dependencies: New constants:
|
19
|
+
Dependencies: called new_constants_in(Object)
|
20
|
+
Dependencies: New constants:
|
21
|
+
Dependencies: New constants:
|
22
|
+
Dependencies: called new_constants_in(Object)
|
23
|
+
Dependencies: called new_constants_in(Object)
|
24
|
+
Dependencies: New constants:
|
25
|
+
Dependencies: called new_constants_in(Object)
|
26
|
+
Dependencies: New constants:
|
27
|
+
Dependencies: called new_constants_in(Object)
|
28
|
+
Dependencies: New constants: OptionParser
|
29
|
+
Dependencies: New constants:
|
30
|
+
Dependencies: New constants:
|
31
|
+
Dependencies: called new_constants_in(Object)
|
32
|
+
Dependencies: called new_constants_in(Object)
|
33
|
+
Dependencies: New constants:
|
34
|
+
Dependencies: called new_constants_in(Object)
|
35
|
+
Dependencies: New constants:
|
36
|
+
Dependencies: called new_constants_in(Object)
|
37
|
+
Dependencies: New constants:
|
38
|
+
Dependencies: called new_constants_in(Object)
|
39
|
+
Dependencies: called new_constants_in(Object)
|
40
|
+
Dependencies: called new_constants_in(Object)
|
41
|
+
Dependencies: called new_constants_in(Object)
|
42
|
+
Dependencies: called new_constants_in(Object)
|
43
|
+
Dependencies: called new_constants_in(Object)
|
44
|
+
Dependencies: called new_constants_in(Object)
|
45
|
+
Dependencies: New constants:
|
46
|
+
Dependencies: New constants:
|
47
|
+
Dependencies: New constants:
|
48
|
+
Dependencies: called new_constants_in(Object)
|
49
|
+
Dependencies: called new_constants_in(Object)
|
50
|
+
Dependencies: New constants:
|
51
|
+
Dependencies: New constants:
|
52
|
+
Dependencies: called new_constants_in(Object)
|
53
|
+
Dependencies: called new_constants_in(Object)
|
54
|
+
Dependencies: New constants:
|
55
|
+
Dependencies: New constants:
|
56
|
+
Dependencies: called new_constants_in(Object)
|
57
|
+
Dependencies: called new_constants_in(Object)
|
58
|
+
Dependencies: New constants:
|
59
|
+
Dependencies: New constants:
|
60
|
+
Dependencies: called new_constants_in(Object)
|
61
|
+
Dependencies: called new_constants_in(Object)
|
62
|
+
Dependencies: New constants:
|
63
|
+
Dependencies: New constants:
|
64
|
+
Dependencies: called new_constants_in(Object)
|
65
|
+
Dependencies: New constants:
|
66
|
+
Dependencies: called new_constants_in(Object)
|
67
|
+
Dependencies: called new_constants_in(Object)
|
68
|
+
Dependencies: New constants:
|
69
|
+
Dependencies: New constants:
|
70
|
+
Dependencies: called new_constants_in(Object)
|
71
|
+
Dependencies: called new_constants_in(Object)
|
72
|
+
Dependencies: New constants:
|
73
|
+
Dependencies: called new_constants_in(Object)
|
74
|
+
Dependencies: New constants:
|
75
|
+
Dependencies: called new_constants_in(Object)
|
76
|
+
Dependencies: New constants:
|
77
|
+
Dependencies: New constants:
|
78
|
+
Dependencies: called new_constants_in(Object)
|
79
|
+
Dependencies: called new_constants_in(Object)
|
80
|
+
Dependencies: New constants:
|
81
|
+
Dependencies: New constants:
|
82
|
+
Dependencies: called new_constants_in(Object)
|
83
|
+
Dependencies: called new_constants_in(Object)
|
84
|
+
Dependencies: New constants:
|
85
|
+
Dependencies: New constants:
|
86
|
+
Dependencies: called new_constants_in(Object)
|
87
|
+
Dependencies: called new_constants_in(Object)
|
88
|
+
Dependencies: New constants:
|
89
|
+
Dependencies: New constants:
|
90
|
+
Dependencies: called new_constants_in(Object)
|
91
|
+
Dependencies: called new_constants_in(Object)
|
92
|
+
Dependencies: New constants:
|
93
|
+
Dependencies: New constants:
|
94
|
+
Dependencies: called new_constants_in(Object)
|
95
|
+
Dependencies: called new_constants_in(Object)
|
96
|
+
Dependencies: New constants:
|
97
|
+
Dependencies: New constants:
|
98
|
+
Dependencies: called new_constants_in(Object)
|
99
|
+
Dependencies: called new_constants_in(Object)
|
100
|
+
Dependencies: New constants:
|
101
|
+
Dependencies: New constants:
|
102
|
+
Dependencies: called new_constants_in(Object)
|
103
|
+
Dependencies: called new_constants_in(Object)
|
104
|
+
Dependencies: New constants:
|
105
|
+
Dependencies: New constants:
|
106
|
+
Dependencies: called new_constants_in(Object)
|
107
|
+
Dependencies: New constants:
|
108
|
+
Dependencies: called new_constants_in(Object)
|
109
|
+
Dependencies: called new_constants_in(Object)
|
110
|
+
Dependencies: New constants:
|
111
|
+
Dependencies: New constants:
|
112
|
+
Dependencies: called new_constants_in(Object)
|
113
|
+
Dependencies: called new_constants_in(Object)
|
114
|
+
Dependencies: New constants:
|
115
|
+
Dependencies: called new_constants_in(Object)
|
116
|
+
Dependencies: New constants:
|
117
|
+
Dependencies: New constants:
|
118
|
+
Dependencies: New constants: Mocha
|
119
|
+
Dependencies: called new_constants_in(Object)
|
120
|
+
Dependencies: called new_constants_in(Object)
|
121
|
+
Dependencies: New constants:
|
122
|
+
Dependencies: called new_constants_in(Object)
|
123
|
+
Dependencies: called new_constants_in(Object)
|
124
|
+
Dependencies: called new_constants_in(Object)
|
125
|
+
Dependencies: New constants:
|
126
|
+
Dependencies: called new_constants_in(Object)
|
127
|
+
Dependencies: called new_constants_in(Object)
|
128
|
+
Dependencies: called new_constants_in(Object)
|
129
|
+
Dependencies: New constants:
|
130
|
+
Dependencies: New constants:
|
131
|
+
Dependencies: called new_constants_in(Object)
|
132
|
+
Dependencies: New constants:
|
133
|
+
Dependencies: New constants:
|
134
|
+
Dependencies: called new_constants_in(Object)
|
135
|
+
Dependencies: called new_constants_in(Object)
|
136
|
+
Dependencies: New constants:
|
137
|
+
Dependencies: New constants:
|
138
|
+
Dependencies: called new_constants_in(Object)
|
139
|
+
Dependencies: called new_constants_in(Object)
|
140
|
+
Dependencies: called new_constants_in(Object)
|
141
|
+
Dependencies: New constants:
|
142
|
+
Dependencies: New constants:
|
143
|
+
Dependencies: New constants:
|
144
|
+
Dependencies: called new_constants_in(Object)
|
145
|
+
Dependencies: New constants:
|
146
|
+
Dependencies: called new_constants_in(Object)
|
147
|
+
Dependencies: called new_constants_in(Object)
|
148
|
+
Dependencies: New constants:
|
149
|
+
Dependencies: called new_constants_in(Object)
|
150
|
+
Dependencies: New constants:
|
151
|
+
Dependencies: called new_constants_in(Object)
|
152
|
+
Dependencies: New constants:
|
153
|
+
Dependencies: New constants:
|
154
|
+
Dependencies: called new_constants_in(Object)
|
155
|
+
Dependencies: New constants:
|
156
|
+
Dependencies: called new_constants_in(Object)
|
157
|
+
Dependencies: New constants:
|
158
|
+
Dependencies: called new_constants_in(Object)
|
159
|
+
Dependencies: New constants:
|
160
|
+
Dependencies: called new_constants_in(Object)
|
161
|
+
Dependencies: New constants:
|
162
|
+
Dependencies: New constants:
|
163
|
+
Dependencies: called new_constants_in(Object)
|
164
|
+
Dependencies: New constants:
|
165
|
+
Dependencies: called new_constants_in(Object)
|
166
|
+
Dependencies: New constants:
|
167
|
+
Dependencies: called new_constants_in(Object)
|
168
|
+
Dependencies: New constants:
|
169
|
+
Dependencies: called new_constants_in(Object)
|
170
|
+
Dependencies: New constants:
|
171
|
+
Dependencies: called new_constants_in(Object)
|
172
|
+
Dependencies: New constants:
|
173
|
+
Dependencies: called new_constants_in(Object)
|
174
|
+
Dependencies: New constants:
|
175
|
+
Dependencies: New constants:
|
176
|
+
Dependencies: called new_constants_in(Object)
|
177
|
+
Dependencies: New constants:
|
178
|
+
Dependencies: called new_constants_in(Object)
|
179
|
+
Dependencies: New constants:
|
180
|
+
Dependencies: called new_constants_in(Object)
|
181
|
+
Dependencies: New constants:
|
182
|
+
Dependencies: called new_constants_in(Object)
|
183
|
+
Dependencies: New constants:
|
184
|
+
Dependencies: called new_constants_in(Object)
|
185
|
+
Dependencies: called new_constants_in(Object)
|
186
|
+
Dependencies: New constants:
|
187
|
+
Dependencies: New constants:
|
188
|
+
Dependencies: New constants:
|
189
|
+
Dependencies: called new_constants_in(Object)
|
190
|
+
Dependencies: New constants:
|
191
|
+
Dependencies: New constants:
|
192
|
+
Dependencies: called new_constants_in(Object)
|
193
|
+
Dependencies: called new_constants_in(Object)
|
194
|
+
Dependencies: New constants:
|
195
|
+
Dependencies: called new_constants_in(Object)
|
196
|
+
Dependencies: called new_constants_in(Object)
|
197
|
+
Dependencies: called new_constants_in(Object)
|
198
|
+
Dependencies: New constants:
|
199
|
+
Dependencies: New constants:
|
200
|
+
Dependencies: New constants:
|
201
|
+
Dependencies: called new_constants_in(Object)
|
202
|
+
Dependencies: New constants:
|
203
|
+
Dependencies: called new_constants_in(Object)
|
204
|
+
Dependencies: called new_constants_in(Object)
|
205
|
+
Dependencies: New constants:
|
206
|
+
Dependencies: New constants:
|
207
|
+
Dependencies: called new_constants_in(Object)
|
208
|
+
Dependencies: called new_constants_in(Object)
|
209
|
+
Dependencies: New constants:
|
210
|
+
Dependencies: New constants:
|
211
|
+
Dependencies: New constants:
|
212
|
+
Dependencies: New constants:
|
213
|
+
Dependencies: called new_constants_in(Object)
|
214
|
+
Dependencies: called new_constants_in(Object)
|
215
|
+
Dependencies: New constants:
|
216
|
+
Dependencies: New constants:
|
217
|
+
Dependencies: called new_constants_in(Object)
|
218
|
+
Dependencies: New constants:
|
219
|
+
Dependencies: called new_constants_in(Object)
|
220
|
+
Dependencies: New constants:
|
221
|
+
Dependencies: New constants:
|
222
|
+
Dependencies: New constants:
|
223
|
+
Dependencies: called new_constants_in(Object)
|
224
|
+
Dependencies: called new_constants_in(Object)
|
225
|
+
Dependencies: New constants:
|
226
|
+
Dependencies: called new_constants_in(Object)
|
227
|
+
Dependencies: New constants:
|
228
|
+
Dependencies: called new_constants_in(Object)
|
229
|
+
Dependencies: New constants: CSV
|
230
|
+
Dependencies: called new_constants_in(Object)
|
231
|
+
Dependencies: New constants:
|
232
|
+
Dependencies: New constants: Fixtures, FixtureClassNotFound, Fixture
|
233
|
+
Dependencies: called new_constants_in(Object)
|
234
|
+
Dependencies: called new_constants_in(Object)
|
235
|
+
Dependencies: New constants:
|
236
|
+
Dependencies: New constants:
|
237
|
+
Dependencies: called new_constants_in(Object)
|
238
|
+
Dependencies: called new_constants_in(Object)
|
239
|
+
Dependencies: called new_constants_in(Object)
|
240
|
+
Dependencies: New constants:
|
241
|
+
Dependencies: called new_constants_in(Object)
|
242
|
+
Dependencies: called new_constants_in(Object)
|
243
|
+
Dependencies: New constants:
|
244
|
+
Dependencies: called new_constants_in(Object)
|
245
|
+
Dependencies: New constants:
|
246
|
+
Dependencies: New constants:
|
247
|
+
Dependencies: called new_constants_in(Object)
|
248
|
+
Dependencies: called new_constants_in(Object)
|
249
|
+
Dependencies: New constants:
|
250
|
+
Dependencies: called new_constants_in(Object)
|
251
|
+
Dependencies: New constants:
|
252
|
+
Dependencies: New constants:
|
253
|
+
Dependencies: called new_constants_in(Object)
|
254
|
+
Dependencies: called new_constants_in(Object)
|
255
|
+
Dependencies: New constants:
|
256
|
+
Dependencies: called new_constants_in(Object)
|
257
|
+
Dependencies: New constants:
|
258
|
+
Dependencies: New constants:
|
259
|
+
Dependencies: called new_constants_in(Object)
|
260
|
+
Dependencies: New constants:
|
261
|
+
Dependencies: called new_constants_in(Object)
|
262
|
+
Dependencies: New constants:
|
263
|
+
Dependencies: called new_constants_in(Object)
|
264
|
+
Dependencies: New constants:
|
265
|
+
Dependencies: New constants:
|
266
|
+
Dependencies: called new_constants_in(Object)
|
267
|
+
Dependencies: New constants:
|
268
|
+
Dependencies: called new_constants_in(Object)
|
269
|
+
Dependencies: New constants:
|
270
|
+
Dependencies: New constants:
|
271
|
+
Dependencies: called new_constants_in(Object)
|
272
|
+
Dependencies: called new_constants_in(Object)
|
273
|
+
Dependencies: New constants:
|
274
|
+
Dependencies: called new_constants_in(Object)
|
275
|
+
Dependencies: New constants:
|
276
|
+
Dependencies: called new_constants_in(Object)
|
277
|
+
Dependencies: New constants:
|
278
|
+
Dependencies: called new_constants_in(Object)
|
279
|
+
Dependencies: New constants:
|
280
|
+
Dependencies: called new_constants_in(Object)
|
281
|
+
Dependencies: New constants:
|
282
|
+
Dependencies: called new_constants_in(Object)
|
283
|
+
Dependencies: New constants:
|
284
|
+
Dependencies: called new_constants_in(Object)
|
285
|
+
Dependencies: New constants:
|
286
|
+
Dependencies: called new_constants_in(Object)
|
287
|
+
Dependencies: New constants:
|
288
|
+
Dependencies: called new_constants_in(Object)
|
289
|
+
Dependencies: New constants:
|
290
|
+
Dependencies: called new_constants_in(Object)
|
291
|
+
Dependencies: New constants:
|
292
|
+
Dependencies: New constants:
|
293
|
+
Dependencies: called new_constants_in(Object)
|
294
|
+
Dependencies: called new_constants_in(Object)
|
295
|
+
Dependencies: New constants:
|
296
|
+
Dependencies: New constants:
|
297
|
+
Dependencies: called new_constants_in(Object)
|
298
|
+
Dependencies: New constants:
|
299
|
+
Dependencies: Error during loading, removing partially loaded constants
|
300
|
+
Dependencies: called new_constants_in(Object)
|
301
|
+
Dependencies: New constants:
|
302
|
+
Dependencies: called new_constants_in(Object)
|
303
|
+
Dependencies: New constants:
|
304
|
+
Dependencies: Error during loading, removing partially loaded constants
|
305
|
+
Dependencies: New constants:
|
306
|
+
[4;36;1mSQL (0.000132)[0m [0;1mSET client_min_messages TO 'panic'[0m
|
307
|
+
[4;35;1mSQL (0.000083)[0m [0mSET client_min_messages TO 'notice'[0m
|
308
|
+
[4;36;1mSQL (0.000089)[0m [0;1mSET client_min_messages TO 'ERROR'[0m
|
309
|
+
Dependencies: called new_constants_in(Object)
|
310
|
+
Dependencies: New constants: CreatePeopleConf
|
311
|
+
[4;35;1mSQL (0.000488)[0m [0mSELECT version FROM schema_migrations[0m
|
312
|
+
Migrating to CreatePeopleConf (1)
|
313
|
+
[4;36;1mSQL (0.000127)[0m [0;1mSELECT version FROM schema_migrations[0m
|
314
|
+
Dependencies: called new_constants_in(Object)
|
315
|
+
Dependencies: called new_constants_in(Object)
|
316
|
+
Dependencies: New constants:
|
317
|
+
Dependencies: New constants:
|
318
|
+
Dependencies: called new_constants_in(Object)
|
319
|
+
Dependencies: called new_constants_in(Object)
|
320
|
+
Dependencies: called new_constants_in(Object)
|
321
|
+
Dependencies: New constants:
|
322
|
+
Dependencies: called new_constants_in(Object)
|
323
|
+
Dependencies: called new_constants_in(Object)
|
324
|
+
Dependencies: New constants:
|
325
|
+
Dependencies: New constants:
|
326
|
+
Dependencies: called new_constants_in(Object)
|
327
|
+
Dependencies: called new_constants_in(Object)
|
328
|
+
Dependencies: New constants:
|
329
|
+
Dependencies: New constants:
|
330
|
+
Dependencies: New constants:
|
331
|
+
Dependencies: called new_constants_in(Object)
|
332
|
+
Dependencies: New constants:
|
333
|
+
Dependencies: New constants:
|
334
|
+
[4;35;1mSQL (0.000141)[0m [0mBEGIN[0m
|
335
|
+
Dependencies: called load_missing_constant(RealFkTest, :PersonType)
|
336
|
+
Dependencies: called load_missing_constant(Object, :PersonType)
|
337
|
+
Dependencies: called require_or_load("/home/gwolf/cvs/realfk/test/rails_root/app/models/person_type.rb", nil)
|
338
|
+
Dependencies: loading /home/gwolf/cvs/realfk/test/rails_root/app/models/person_type
|
339
|
+
Dependencies: called load_file("/home/gwolf/cvs/realfk/test/rails_root/app/models/person_type.rb", ["Models::PersonType", "PersonType"])
|
340
|
+
Dependencies: called new_constants_in("Models", :Object)
|
341
|
+
Dependencies: New constants: PersonType
|
342
|
+
Dependencies: loading /home/gwolf/cvs/realfk/test/rails_root/app/models/person_type.rb defined PersonType
|
343
|
+
[4;36;1mPersonType Load (0.000614)[0m [0;1mSELECT * FROM "person_types" [0m
|
344
|
+
Dependencies: called load_missing_constant(RealFkTest, :Person)
|
345
|
+
Dependencies: called load_missing_constant(Object, :Person)
|
346
|
+
Dependencies: called require_or_load("/home/gwolf/cvs/realfk/test/rails_root/app/models/person.rb", nil)
|
347
|
+
Dependencies: loading /home/gwolf/cvs/realfk/test/rails_root/app/models/person
|
348
|
+
Dependencies: called load_file("/home/gwolf/cvs/realfk/test/rails_root/app/models/person.rb", ["Models::Person", "Person"])
|
349
|
+
Dependencies: called new_constants_in("Models", :Object)
|
350
|
+
Dependencies: New constants: Person
|
351
|
+
Dependencies: loading /home/gwolf/cvs/realfk/test/rails_root/app/models/person.rb defined Person
|
352
|
+
[4;35;1mPerson Load (0.000627)[0m [0mSELECT * FROM "people" LIMIT 1[0m
|
353
|
+
[4;36;1mPerson Update (0.000000)[0m [0;1mPGError: ERROR: null value in column "person_type_id" violates not-null constraint
|
354
|
+
: UPDATE "people" SET "person_type_id" = NULL WHERE "id" = 2[0m
|
355
|
+
[4;35;1mSQL (0.000182)[0m [0mSET client_min_messages TO 'ERROR'[0m
|
356
|
+
[4;36;1mPerson Update (0.000000)[0m [0;1mPGError: ERROR: insert or update on table "people" violates foreign key constraint "people_person_type_id_fkey"
|
357
|
+
DETAIL: Key (person_type_id)=(4) is not present in table "person_types".
|
358
|
+
: UPDATE "people" SET "person_type_id" = 4 WHERE "id" = 2[0m
|
359
|
+
[4;35;1mSQL (0.000185)[0m [0mSET client_min_messages TO 'ERROR'[0m
|
360
|
+
[4;36;1mPerson Update (0.002232)[0m [0;1mUPDATE "people" SET "person_type_id" = 3 WHERE "id" = 2[0m
|
361
|
+
[4;35;1mPerson Load (0.000336)[0m [0mSELECT * FROM "people" WHERE ("people"."id" = 2) [0m
|
362
|
+
[4;36;1mPerson Exists (0.000360)[0m [0;1mSELECT "people".id FROM "people" WHERE ("people"."id" = 2) AND ("people".person_type_id = 3) LIMIT 1[0m
|
363
|
+
[4;35;1mPersonType Load (0.000433)[0m [0mSELECT * FROM "person_types" WHERE ("person_types"."id" = 3) [0m
|
364
|
+
[4;36;1mSQL (0.000223)[0m [0;1mROLLBACK[0m
|
365
|
+
[4;35;1mSQL (0.000060)[0m [0mBEGIN[0m
|
366
|
+
Dependencies: called load_missing_constant(RealFkTest, :Conference)
|
367
|
+
Dependencies: called load_missing_constant(Object, :Conference)
|
368
|
+
Dependencies: called require_or_load("/home/gwolf/cvs/realfk/test/rails_root/app/models/conference.rb", nil)
|
369
|
+
Dependencies: loading /home/gwolf/cvs/realfk/test/rails_root/app/models/conference
|
370
|
+
Dependencies: called load_file("/home/gwolf/cvs/realfk/test/rails_root/app/models/conference.rb", ["Models::Conference", "Conference"])
|
371
|
+
Dependencies: called new_constants_in("Models", :Object)
|
372
|
+
Dependencies: New constants: Conference
|
373
|
+
Dependencies: loading /home/gwolf/cvs/realfk/test/rails_root/app/models/conference.rb defined Conference
|
374
|
+
[4;36;1mConference Load (0.000496)[0m [0;1mSELECT * FROM "conferences" [0m
|
375
|
+
[4;35;1mPerson Load (0.000146)[0m [0mSELECT * FROM "people" [0m
|
376
|
+
[4;36;1mPerson Load (0.000740)[0m [0;1mSELECT * FROM "people" INNER JOIN "conferences_people" ON "people".id = "conferences_people".person_id WHERE ("conferences_people".conference_id = 3 ) [0m
|
377
|
+
[4;35;1mSQL (0.000684)[0m [0mINSERT INTO "conferences_people" ("person_id", "conference_id") VALUES (3, 3)[0m
|
378
|
+
[4;36;1mSQL (0.000232)[0m [0;1mINSERT INTO "conferences_people" ("person_id", "conference_id") VALUES (1, 3)[0m
|
379
|
+
[4;35;1mSQL (0.000234)[0m [0mINSERT INTO "conferences_people" ("person_id", "conference_id") VALUES (2, 3)[0m
|
380
|
+
[4;36;1mPerson Load (0.000151)[0m [0;1mSELECT * FROM "people" [0m
|
381
|
+
[4;35;1mConference Exists (0.000419)[0m [0mSELECT "conferences".id FROM "conferences" INNER JOIN "conferences_people" ON "conferences".id = "conferences_people".conference_id WHERE ("conferences"."id" = 3) AND ("conferences_people".person_id = 3 ) LIMIT 1[0m
|
382
|
+
[4;36;1mConference Exists (0.000331)[0m [0;1mSELECT "conferences".id FROM "conferences" INNER JOIN "conferences_people" ON "conferences".id = "conferences_people".conference_id WHERE ("conferences"."id" = 3) AND ("conferences_people".person_id = 1 ) LIMIT 1[0m
|
383
|
+
[4;35;1mConference Exists (0.000322)[0m [0mSELECT "conferences".id FROM "conferences" INNER JOIN "conferences_people" ON "conferences".id = "conferences_people".conference_id WHERE ("conferences"."id" = 3) AND ("conferences_people".person_id = 2 ) LIMIT 1[0m
|
384
|
+
[4;36;1mPerson Load (0.000138)[0m [0;1mSELECT * FROM "people" [0m
|
385
|
+
[4;35;1mConference Load (0.000372)[0m [0mSELECT * FROM "conferences" INNER JOIN "conferences_people" ON "conferences".id = "conferences_people".conference_id WHERE ("conferences_people".person_id = 3 ) [0m
|
386
|
+
[4;36;1mSQL (0.000260)[0m [0;1mDELETE FROM "conferences_people" WHERE person_id = 3 AND conference_id IN (3)[0m
|
387
|
+
[4;35;1mSQL (0.000235)[0m [0mINSERT INTO "conferences_people" ("person_id", "conference_id") VALUES (3, 4)[0m
|
388
|
+
[4;36;1mConference Load (0.000196)[0m [0;1mSELECT * FROM "conferences" WHERE ("conferences"."id" = 3) [0m
|
389
|
+
[4;35;1mConference Load (0.000163)[0m [0mSELECT * FROM "conferences" WHERE ("conferences"."id" = 4) [0m
|
390
|
+
[4;36;1mPerson Exists (0.000361)[0m [0;1mSELECT "people".id FROM "people" INNER JOIN "conferences_people" ON "people".id = "conferences_people".person_id WHERE ("people"."id" = 3) AND ("conferences_people".conference_id = 4 ) LIMIT 1[0m
|
391
|
+
[4;35;1mPerson Exists (0.000327)[0m [0mSELECT "people".id FROM "people" INNER JOIN "conferences_people" ON "people".id = "conferences_people".person_id WHERE ("people"."id" = 3) AND ("conferences_people".conference_id = 3 ) LIMIT 1[0m
|
392
|
+
[4;36;1mConference Load (0.000134)[0m [0;1mSELECT * FROM "conferences" [0m
|
393
|
+
[4;35;1mConference Load (0.000366)[0m [0mSELECT * FROM "conferences" INNER JOIN "conferences_people" ON "conferences".id = "conferences_people".conference_id WHERE ("conferences_people".person_id = 1 ) [0m
|
394
|
+
[4;36;1mSQL (0.000234)[0m [0;1mINSERT INTO "conferences_people" ("person_id", "conference_id") VALUES (1, 1)[0m
|
395
|
+
[4;35;1mSQL (0.000228)[0m [0mINSERT INTO "conferences_people" ("person_id", "conference_id") VALUES (1, 2)[0m
|
396
|
+
[4;36;1mSQL (0.000227)[0m [0;1mINSERT INTO "conferences_people" ("person_id", "conference_id") VALUES (1, 4)[0m
|
397
|
+
[4;35;1mConference Load (0.000197)[0m [0mSELECT * FROM "conferences" WHERE ("conferences"."id" = 3) [0m
|
398
|
+
[4;36;1mConference Load (0.000162)[0m [0;1mSELECT * FROM "conferences" WHERE ("conferences"."id" = 4) [0m
|
399
|
+
[4;35;1mPerson Exists (0.000361)[0m [0mSELECT "people".id FROM "people" INNER JOIN "conferences_people" ON "people".id = "conferences_people".person_id WHERE ("people"."id" = 1) AND ("conferences_people".conference_id = 3 ) LIMIT 1[0m
|
400
|
+
[4;36;1mPerson Exists (0.000332)[0m [0;1mSELECT "people".id FROM "people" INNER JOIN "conferences_people" ON "people".id = "conferences_people".person_id WHERE ("people"."id" = 1) AND ("conferences_people".conference_id = 4 ) LIMIT 1[0m
|
401
|
+
[4;35;1mSQL (0.000112)[0m [0mROLLBACK[0m
|
402
|
+
[4;36;1mSQL (0.000114)[0m [0;1mBEGIN[0m
|
403
|
+
[4;35;1mSQL (0.000056)[0m [0mROLLBACK[0m
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Load the environment
|
2
|
+
ENV['RAILS_ENV'] ||= 'postgresql'
|
3
|
+
require File.dirname(__FILE__) + '/rails_root/config/environment.rb'
|
4
|
+
|
5
|
+
# Load the testing framework
|
6
|
+
require 'test_help'
|
7
|
+
silence_warnings { RAILS_ENV = ENV['RAILS_ENV'] }
|
8
|
+
|
9
|
+
# Run the migrations
|
10
|
+
ActiveRecord::Migrator.migrate("#{RAILS_ROOT}/db/migrate")
|
11
|
+
|
12
|
+
# Setup the fixtures path
|
13
|
+
Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
|
14
|
+
$LOAD_PATH.unshift(Test::Unit::TestCase.fixture_path)
|
15
|
+
|
16
|
+
class Test::Unit::TestCase #:nodoc:
|
17
|
+
def create_fixtures(*table_names)
|
18
|
+
if block_given?
|
19
|
+
Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names) { yield }
|
20
|
+
else
|
21
|
+
Fixtures.create_fixtures(Test::Unit::TestCase.fixture_path, table_names)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
self.use_transactional_fixtures = true
|
26
|
+
self.use_instantiated_fixtures = false
|
27
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
|
3
|
+
class RealFkTest < ActiveSupport::TestCase
|
4
|
+
def test_relation_defined
|
5
|
+
assert Person.column_names.include?('person_type_id')
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_constraints_in_place
|
9
|
+
types = PersonType.find(:all)
|
10
|
+
|
11
|
+
# We didn't specify any validations in the model - So a person without a
|
12
|
+
# person_type must be valid, although will bomb when saving it.
|
13
|
+
person = Person.find(:first)
|
14
|
+
person.person_type = nil
|
15
|
+
assert person.valid?
|
16
|
+
assert_raises(ActiveRecord::StatementInvalid) { person.save }
|
17
|
+
|
18
|
+
# An exception was raised - The DB won't like it!
|
19
|
+
ActiveRecord::Base.connection.reconnect!
|
20
|
+
|
21
|
+
# ...Of course, giving an invalid person type also fails
|
22
|
+
highest_type = types.sort {|a,b| a.id <=> b.id}.last
|
23
|
+
person.person_type_id = highest_type.id + 1
|
24
|
+
assert person.valid?
|
25
|
+
assert_raises(ActiveRecord::StatementInvalid) { person.save }
|
26
|
+
|
27
|
+
# An exception was raised - The DB won't like it!
|
28
|
+
ActiveRecord::Base.connection.reconnect!
|
29
|
+
|
30
|
+
# But if it is a valid type, the person will be properly and finally saved
|
31
|
+
person.person_type_id = highest_type.id
|
32
|
+
assert person.save
|
33
|
+
|
34
|
+
# Finally, check the relation is in effect and Rails gets it. It looks
|
35
|
+
# contorted... :-}
|
36
|
+
people = highest_type.people
|
37
|
+
assert people.include?(Person.find(person.id))
|
38
|
+
assert_equal(highest_type.id, person.person_type.id)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_habtm
|
42
|
+
(c1, c2) = Conference.find(:all).sort_by{rand}
|
43
|
+
|
44
|
+
# Just set up some relations and check they get saved...
|
45
|
+
# Everybody goes to conference 1!
|
46
|
+
c1.people = Person.find(:all)
|
47
|
+
Person.find(:all).map {|p| assert p.conferences.include?(c1) }
|
48
|
+
|
49
|
+
# Person 2 will only go to conference 2, not to conference 1.
|
50
|
+
# Rails is lazy on related items - Force it to reload.
|
51
|
+
(p1, p2) = Person.find(:all).sort_by{rand}
|
52
|
+
p1.conferences = [c2]
|
53
|
+
c1.reload
|
54
|
+
c2.reload
|
55
|
+
assert c2.people.include?(p1)
|
56
|
+
assert ! c1.people.include?(p1)
|
57
|
+
|
58
|
+
# Person 2 will only go every conference!
|
59
|
+
# Rails is lazy on related items - Force it to reload.
|
60
|
+
p2.conferences = Conference.find(:all)
|
61
|
+
c1.reload
|
62
|
+
c2.reload
|
63
|
+
assert c1.people.include?(p2)
|
64
|
+
assert c2.people.include?(p2)
|
65
|
+
end
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: real_fk
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gunnar Wolf
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-11-25 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: This plugin extends the base <tt>Rails ActiveRecord::Migration</tt> with some commonly used functionality, aiming at keeping your migrations short, easy to understand and meaningful.
|
17
|
+
email: gwolf@gwolf.org
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
files:
|
25
|
+
- test/rails_root
|
26
|
+
- test/rails_root/log
|
27
|
+
- test/rails_root/log/postgresql.log
|
28
|
+
- test/rails_root/script
|
29
|
+
- test/rails_root/script/console
|
30
|
+
- test/rails_root/config
|
31
|
+
- test/rails_root/config/boot.rb
|
32
|
+
- test/rails_root/config/database.yml
|
33
|
+
- test/rails_root/config/environments
|
34
|
+
- test/rails_root/config/environments/postgresql.rb
|
35
|
+
- test/rails_root/config/environments/sqlite3.rb
|
36
|
+
- test/rails_root/config/environments/mysql.rb
|
37
|
+
- test/rails_root/config/environments/sqlite.rb
|
38
|
+
- test/rails_root/config/routes.rb
|
39
|
+
- test/rails_root/config/environment.rb
|
40
|
+
- test/rails_root/README
|
41
|
+
- test/rails_root/db
|
42
|
+
- test/rails_root/db/migrate
|
43
|
+
- test/rails_root/db/migrate/001_create_people_conf.rb
|
44
|
+
- test/rails_root/vendor
|
45
|
+
- test/rails_root/vendor/plugins
|
46
|
+
- test/rails_root/vendor/plugins/real_fk
|
47
|
+
- test/rails_root/vendor/plugins/real_fk/init.rb
|
48
|
+
- test/rails_root/vendor/rails
|
49
|
+
- test/rails_root/app
|
50
|
+
- test/rails_root/app/models
|
51
|
+
- test/rails_root/app/models/person.rb
|
52
|
+
- test/rails_root/app/models/conference.rb
|
53
|
+
- test/rails_root/app/models/person_type.rb
|
54
|
+
- test/rails_root/app/controllers
|
55
|
+
- test/rails_root/app/controllers/application.rb
|
56
|
+
- test/test_helper.rb
|
57
|
+
- test/unit
|
58
|
+
- test/unit/real_fk_test.rb
|
59
|
+
- lib/real_fk.rb
|
60
|
+
- Manifest.txt
|
61
|
+
- LICENSE
|
62
|
+
- README
|
63
|
+
- CHANGELOG
|
64
|
+
has_rdoc: true
|
65
|
+
homepage: http://realfk.rubyforge.org/
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options:
|
68
|
+
- --line-numbers
|
69
|
+
- --inline-source
|
70
|
+
- charset
|
71
|
+
- utf-8
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project: realfk
|
89
|
+
rubygems_version: 1.2.0
|
90
|
+
signing_key:
|
91
|
+
specification_version: 2
|
92
|
+
summary: Rails plugin aimed towards simplifying declaration and usage of tables with proper foreign key constraints.
|
93
|
+
test_files: []
|
94
|
+
|