rails 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rails might be problematic. Click here for more details.
- data/CHANGELOG +34 -0
- data/Rakefile +14 -16
- data/bin/runner +4 -0
- data/configs/apache.conf +13 -2
- data/configs/routes.rb +5 -1
- data/dispatches/dispatch.fcgi +18 -12
- data/environments/{shared.rb → environment.rb} +20 -20
- data/fresh_rakefile +33 -24
- data/html/javascripts/prototype.js +336 -0
- data/lib/rails_generator/generators/applications/app/app_generator.rb +5 -6
- data/lib/rails_generator/generators/components/model/USAGE +1 -1
- data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +23 -23
- data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +11 -11
- data/lib/rails_generator/generators/components/scaffold/templates/form.rhtml +3 -5
- data/lib/rails_generator/generators/components/scaffold/templates/form_scaffolding.rhtml +1 -0
- data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +14 -14
- data/lib/rails_generator/generators/components/scaffold/templates/layout.rhtml +1 -1
- data/lib/rails_generator/generators/components/scaffold/templates/view_edit.rhtml +5 -3
- data/lib/rails_generator/generators/components/scaffold/templates/view_list.rhtml +5 -5
- data/lib/rails_generator/generators/components/scaffold/templates/view_new.rhtml +4 -2
- data/lib/rails_generator/generators/components/scaffold/templates/view_show.rhtml +3 -3
- data/lib/webrick_server.rb +2 -0
- metadata +13 -10
- data/environments/shared_for_gem.rb +0 -66
data/CHANGELOG
CHANGED
@@ -1,3 +1,37 @@
|
|
1
|
+
*0.11.0* (22th March, 2005)
|
2
|
+
|
3
|
+
* Removed SCRIPT_NAME from the WEBrick environment to prevent conflicts with PATH_INFO #896 [Nicholas Seckar]
|
4
|
+
|
5
|
+
* Removed ?$1 from the dispatch.f/cgi redirect line to get rid of 'complete/path/from/request.html' => nil being in the @params now that the ENV["REQUEST_URI"] is used to determine the path #895 [dblack/Nicholas Seckar]
|
6
|
+
|
7
|
+
* Added additional error handling to the FastCGI dispatcher to catch even errors taking down the entire process
|
8
|
+
|
9
|
+
* Improved the generated scaffold code a lot to take advantage of recent Rails developments #882 [Tobias Luetke]
|
10
|
+
|
11
|
+
* Combined the script/environment.rb used for gems and regular files version. If vendor/rails/* has all the frameworks, then files version is used, otherwise gems #878 [Nicholas Seckar]
|
12
|
+
|
13
|
+
* Changed .htaccess to allow dispatch.* to be called from a sub-directory as part of the push with Action Pack to make Rails work on non-vhost setups #826 [Nicholas Seckar/Tobias Luetke]
|
14
|
+
|
15
|
+
* Added script/runner which can be used to run code inside the environment by eval'ing the first parameter. Examples:
|
16
|
+
|
17
|
+
./script/runner 'ReminderService.deliver'
|
18
|
+
./script/runner 'Mailer.receive(STDIN.read)'
|
19
|
+
|
20
|
+
This makes it easier to do CRON and postfix scripts without actually making a script just to trigger 1 line of code.
|
21
|
+
|
22
|
+
* Fixed webrick_server cookie handling to allow multiple cookes to be set at once #800, #813 [dave@cherryville.org]
|
23
|
+
|
24
|
+
* Fixed the Rakefile's interaction with postgresql to:
|
25
|
+
|
26
|
+
1. Use PGPASSWORD and PGHOST in the environment to fix prompting for
|
27
|
+
passwords when connecting to a remote db and local socket connections.
|
28
|
+
2. Add a '-x' flag to pg_dump which stops it dumping privileges #807 [rasputnik]
|
29
|
+
3. Quote the user name and use template0 when dumping so the functions doesn't get dumped too #855 [pburleson]
|
30
|
+
4. Use the port if available #875 [madrobby]
|
31
|
+
|
32
|
+
* Upgraded to Active Record 1.9.0, Action Pack 1.6.0, Action Mailer 0.8.0, Action Web Service 0.6.1, Active Support 1.0.2
|
33
|
+
|
34
|
+
|
1
35
|
*0.10.1* (7th March, 2005)
|
2
36
|
|
3
37
|
* Fixed rake stats to ignore editor backup files like model.rb~ #791 [skanthak]
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ require 'rbconfig'
|
|
9
9
|
|
10
10
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
11
11
|
PKG_NAME = 'rails'
|
12
|
-
PKG_VERSION = '0.
|
12
|
+
PKG_VERSION = '0.11.0' + PKG_BUILD
|
13
13
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
14
14
|
PKG_DESTINATION = ENV["RAILS_PKG_DESTINATION"] || "../#{PKG_NAME}"
|
15
15
|
|
@@ -20,8 +20,8 @@ PUBLIC_DIRS = %w( images javascripts stylesheets )
|
|
20
20
|
TEST_DIRS = %w( fixtures unit functional mocks mocks/development mocks/test )
|
21
21
|
|
22
22
|
LOG_FILES = %w( server.log development.log test.log production.log )
|
23
|
-
HTML_FILES = %w( 404.html 500.html index.html favicon.ico )
|
24
|
-
BIN_FILES = %w( generate destroy breakpointer console server update )
|
23
|
+
HTML_FILES = %w( 404.html 500.html index.html favicon.ico javascripts/prototype.js )
|
24
|
+
BIN_FILES = %w( generate destroy breakpointer console server update runner )
|
25
25
|
|
26
26
|
VENDOR_LIBS = %w( actionpack activerecord actionmailer activesupport actionwebservice railties )
|
27
27
|
|
@@ -90,16 +90,14 @@ end
|
|
90
90
|
|
91
91
|
desc "Copy in all the Rails packages to vendor"
|
92
92
|
task :copy_vendor_libraries do
|
93
|
-
|
94
|
-
|
93
|
+
mkdir File.join(PKG_DESTINATION, 'vendor', 'rails')
|
94
|
+
VENDOR_LIBS.each { |dir| cp_r File.join('..', dir), File.join(PKG_DESTINATION, 'vendor', 'rails', dir) }
|
95
95
|
end
|
96
96
|
|
97
97
|
desc "Link in all the Rails packages to vendor"
|
98
98
|
task :link_vendor_libraries do
|
99
|
-
|
100
|
-
|
101
|
-
VENDOR_LIBS.each { |dir| ln_s File.dirname(__FILE__) + "/../../#{dir}", "." }
|
102
|
-
cd return_dir
|
99
|
+
mkdir File.join(PKG_DESTINATION, 'vendor', 'rails')
|
100
|
+
VENDOR_LIBS.each { |dir| ln_s File.join('..', '..', '..', dir), File.join(PKG_DESTINATION, 'vendor', 'rails', dir) }
|
103
101
|
end
|
104
102
|
|
105
103
|
|
@@ -138,7 +136,7 @@ task :copy_configs do
|
|
138
136
|
|
139
137
|
cp "configs/apache.conf", "#{PKG_DESTINATION}/public/.htaccess"
|
140
138
|
|
141
|
-
cp "environments/
|
139
|
+
cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb"
|
142
140
|
cp "environments/production.rb", "#{PKG_DESTINATION}/config/environments/production.rb"
|
143
141
|
cp "environments/development.rb", "#{PKG_DESTINATION}/config/environments/development.rb"
|
144
142
|
cp "environments/test.rb", "#{PKG_DESTINATION}/config/environments/test.rb"
|
@@ -207,7 +205,7 @@ end
|
|
207
205
|
# Generate GEM ----------------------------------------------------------------------------
|
208
206
|
|
209
207
|
task :copy_gem_environment do
|
210
|
-
cp "environments/
|
208
|
+
cp "environments/environment.rb", "#{PKG_DESTINATION}/config/environment.rb"
|
211
209
|
dest_file = File.join(PKG_DESTINATION, 'script', 'breakpointer')
|
212
210
|
copy_with_rewritten_ruby_path(File.join('bin', 'breakpointer_for_gem'), dest_file)
|
213
211
|
chmod 0755, dest_file
|
@@ -237,11 +235,11 @@ spec = Gem::Specification.new do |s|
|
|
237
235
|
EOF
|
238
236
|
|
239
237
|
s.add_dependency('rake', '>= 0.4.15')
|
240
|
-
s.add_dependency('activesupport', '= 1.0.
|
241
|
-
s.add_dependency('activerecord', '= 1.
|
242
|
-
s.add_dependency('actionpack', '= 1.
|
243
|
-
s.add_dependency('actionmailer', '= 0.
|
244
|
-
s.add_dependency('actionwebservice', '= 0.6.
|
238
|
+
s.add_dependency('activesupport', '= 1.0.2' + PKG_BUILD)
|
239
|
+
s.add_dependency('activerecord', '= 1.9.0' + PKG_BUILD)
|
240
|
+
s.add_dependency('actionpack', '= 1.6.0' + PKG_BUILD)
|
241
|
+
s.add_dependency('actionmailer', '= 0.8.0' + PKG_BUILD)
|
242
|
+
s.add_dependency('actionwebservice', '= 0.6.1' + PKG_BUILD)
|
245
243
|
|
246
244
|
s.rdoc_options << '--exclude' << '.'
|
247
245
|
s.has_rdoc = false
|
data/bin/runner
ADDED
data/configs/apache.conf
CHANGED
@@ -4,11 +4,22 @@ AddHandler cgi-script .cgi
|
|
4
4
|
Options +FollowSymLinks +ExecCGI
|
5
5
|
|
6
6
|
# Redirect all requests not available on the filesystem to Rails
|
7
|
+
# By default the cgi dispatcher is used which is very slow
|
8
|
+
#
|
9
|
+
# For better performance replace the dispatcher with the fastcgi one
|
10
|
+
#
|
11
|
+
# Example:
|
12
|
+
# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
|
7
13
|
RewriteEngine On
|
8
14
|
RewriteRule ^$ index.html [QSA]
|
9
15
|
RewriteRule ^([^.]+)$ $1.html [QSA]
|
10
16
|
RewriteCond %{REQUEST_FILENAME} !-f
|
11
|
-
RewriteRule ^(.*)$
|
17
|
+
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
|
12
18
|
|
13
19
|
# In case Rails experiences terminal errors
|
14
|
-
|
20
|
+
# Instead of displaying this message you can supply a file here which will be rendered instead
|
21
|
+
#
|
22
|
+
# Example:
|
23
|
+
# ErrorDocument 500 /500.html
|
24
|
+
|
25
|
+
ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
|
data/configs/routes.rb
CHANGED
@@ -6,10 +6,14 @@ ActionController::Routing::Routes.draw do |map|
|
|
6
6
|
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
|
7
7
|
# Keep in mind you can assign values other than :controller and :action
|
8
8
|
|
9
|
+
# You can have the root of your site routed by hooking up ''
|
10
|
+
# -- just remember to delete public/index.html.
|
11
|
+
# map.connect '', :controller => "welcome"
|
12
|
+
|
9
13
|
# Allow downloading Web Service WSDL as a file with an extension
|
10
14
|
# instead of a file named 'wsdl'
|
11
15
|
map.connect ':controller/service.wsdl', :action => 'wsdl'
|
12
|
-
|
16
|
+
|
13
17
|
# Install the default route as the lowest priority.
|
14
18
|
map.connect ':controller/:action/:id'
|
15
19
|
end
|
data/dispatches/dispatch.fcgi
CHANGED
@@ -1,20 +1,26 @@
|
|
1
1
|
#!/usr/local/bin/ruby
|
2
2
|
|
3
|
-
|
4
|
-
require 'dispatcher'
|
5
|
-
require 'fcgi'
|
3
|
+
FASTCGI_CRASH_LOG_PATH = "#{RAILS_ROOT}/log/fastcgi.crash.log"
|
6
4
|
|
7
|
-
|
5
|
+
def dispatcher_error(e, msg = "")
|
6
|
+
error_message = "[#{Time.now}] Dispatcher failed to catch: #{e} (#{e.class})\n #{e.backtrace.join("\n ")}\n#{msg}"
|
7
|
+
Logger.new(FASTCGI_CRASH_LOG_PATH).fatal(error_message)
|
8
|
+
rescue Object => log_error
|
9
|
+
STDERR << "Couldn't write to #{FASTCGI_CRASH_LOG_PATH} (#{e} [#{e.class}])\n" << error_message
|
10
|
+
end
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
begin
|
13
|
+
require File.dirname(__FILE__) + "/../config/environment"
|
14
|
+
require 'dispatcher'
|
15
|
+
require 'fcgi'
|
16
|
+
|
17
|
+
FCGI.each_cgi do |cgi|
|
14
18
|
begin
|
15
|
-
|
16
|
-
rescue Object =>
|
17
|
-
|
19
|
+
Dispatcher.dispatch(cgi)
|
20
|
+
rescue Object => rails_error
|
21
|
+
dispatcher_error(rails_error)
|
18
22
|
end
|
19
23
|
end
|
24
|
+
rescue Object => fcgi_error
|
25
|
+
dispatcher_error(fcgi_error, "FCGI process #{$$} killed by this error\n")
|
20
26
|
end
|
@@ -11,39 +11,39 @@ ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/components/[_a-z]*"])
|
|
11
11
|
|
12
12
|
# Followed by the standard includes.
|
13
13
|
ADDITIONAL_LOAD_PATHS.concat %w(
|
14
|
-
app
|
15
|
-
app/models
|
16
|
-
app/controllers
|
17
|
-
app/helpers
|
18
|
-
app/apis
|
19
|
-
|
20
|
-
|
21
|
-
lib
|
22
|
-
vendor
|
23
|
-
vendor/railties
|
24
|
-
vendor/railties/lib
|
25
|
-
vendor/
|
26
|
-
vendor/
|
27
|
-
vendor/
|
28
|
-
vendor/actionmailer/lib
|
29
|
-
vendor/actionwebservice/lib
|
30
|
-
).map { |dir| "#{RAILS_ROOT}/#{dir}" }
|
14
|
+
app
|
15
|
+
app/models
|
16
|
+
app/controllers
|
17
|
+
app/helpers
|
18
|
+
app/apis
|
19
|
+
components
|
20
|
+
config
|
21
|
+
lib
|
22
|
+
vendor
|
23
|
+
vendor/rails/railties
|
24
|
+
vendor/rails/railties/lib
|
25
|
+
vendor/rails/actionpack/lib
|
26
|
+
vendor/rails/activesupport/lib
|
27
|
+
vendor/rails/activerecord/lib
|
28
|
+
vendor/rails/actionmailer/lib
|
29
|
+
vendor/rails/actionwebservice/lib
|
30
|
+
).map { |dir| "#{RAILS_ROOT}/#{dir}" }.select { |dir| File.directory?(dir) }
|
31
31
|
|
32
32
|
# Prepend to $LOAD_PATH
|
33
33
|
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
|
34
34
|
|
35
|
-
|
36
35
|
# Require Rails libraries.
|
36
|
+
require 'rubygems' unless File.directory?("#{RAILS_ROOT}/vendor/rails")
|
37
|
+
|
37
38
|
require 'active_support'
|
38
39
|
require 'active_record'
|
39
40
|
require 'action_controller'
|
40
41
|
require 'action_mailer'
|
41
42
|
require 'action_web_service'
|
42
43
|
|
43
|
-
|
44
44
|
# Environment-specific configuration.
|
45
45
|
require_dependency "environments/#{RAILS_ENV}"
|
46
|
-
ActiveRecord::Base.configurations =
|
46
|
+
ActiveRecord::Base.configurations = File.open("#{RAILS_ROOT}/config/database.yml") { |f| YAML::load(f) }
|
47
47
|
ActiveRecord::Base.establish_connection
|
48
48
|
|
49
49
|
|
data/fresh_rakefile
CHANGED
@@ -75,24 +75,24 @@ Rake::RDocTask.new("apidoc") { |rdoc|
|
|
75
75
|
rdoc.options << '--line-numbers --inline-source'
|
76
76
|
rdoc.rdoc_files.include('README')
|
77
77
|
rdoc.rdoc_files.include('CHANGELOG')
|
78
|
-
rdoc.rdoc_files.include('vendor/railties/CHANGELOG')
|
79
|
-
rdoc.rdoc_files.include('vendor/railties/MIT-LICENSE')
|
80
|
-
rdoc.rdoc_files.include('vendor/activerecord/README')
|
81
|
-
rdoc.rdoc_files.include('vendor/activerecord/CHANGELOG')
|
82
|
-
rdoc.rdoc_files.include('vendor/activerecord/lib/active_record/**/*.rb')
|
83
|
-
rdoc.rdoc_files.exclude('vendor/activerecord/lib/active_record/vendor/*')
|
84
|
-
rdoc.rdoc_files.include('vendor/actionpack/README')
|
85
|
-
rdoc.rdoc_files.include('vendor/actionpack/CHANGELOG')
|
86
|
-
rdoc.rdoc_files.include('vendor/actionpack/lib/action_controller/**/*.rb')
|
87
|
-
rdoc.rdoc_files.include('vendor/actionpack/lib/action_view/**/*.rb')
|
88
|
-
rdoc.rdoc_files.include('vendor/actionmailer/README')
|
89
|
-
rdoc.rdoc_files.include('vendor/actionmailer/CHANGELOG')
|
90
|
-
rdoc.rdoc_files.include('vendor/actionmailer/lib/action_mailer/base.rb')
|
91
|
-
rdoc.rdoc_files.include('vendor/actionwebservice/README')
|
92
|
-
rdoc.rdoc_files.include('vendor/actionwebservice/ChangeLog')
|
93
|
-
rdoc.rdoc_files.include('vendor/actionwebservice/lib/action_web_service/**/*.rb')
|
94
|
-
rdoc.rdoc_files.include('vendor/activesupport/README')
|
95
|
-
rdoc.rdoc_files.include('vendor/activesupport/lib/active_support/**/*.rb')
|
78
|
+
rdoc.rdoc_files.include('vendor/rails/railties/CHANGELOG')
|
79
|
+
rdoc.rdoc_files.include('vendor/rails/railties/MIT-LICENSE')
|
80
|
+
rdoc.rdoc_files.include('vendor/rails/activerecord/README')
|
81
|
+
rdoc.rdoc_files.include('vendor/rails/activerecord/CHANGELOG')
|
82
|
+
rdoc.rdoc_files.include('vendor/rails/activerecord/lib/active_record/**/*.rb')
|
83
|
+
rdoc.rdoc_files.exclude('vendor/rails/activerecord/lib/active_record/vendor/*')
|
84
|
+
rdoc.rdoc_files.include('vendor/rails/actionpack/README')
|
85
|
+
rdoc.rdoc_files.include('vendor/rails/actionpack/CHANGELOG')
|
86
|
+
rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_controller/**/*.rb')
|
87
|
+
rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_view/**/*.rb')
|
88
|
+
rdoc.rdoc_files.include('vendor/rails/actionmailer/README')
|
89
|
+
rdoc.rdoc_files.include('vendor/rails/actionmailer/CHANGELOG')
|
90
|
+
rdoc.rdoc_files.include('vendor/rails/actionmailer/lib/action_mailer/base.rb')
|
91
|
+
rdoc.rdoc_files.include('vendor/rails/actionwebservice/README')
|
92
|
+
rdoc.rdoc_files.include('vendor/rails/actionwebservice/ChangeLog')
|
93
|
+
rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/**/*.rb')
|
94
|
+
rdoc.rdoc_files.include('vendor/rails/activesupport/README')
|
95
|
+
rdoc.rdoc_files.include('vendor/rails/activesupport/lib/active_support/**/*.rb')
|
96
96
|
}
|
97
97
|
|
98
98
|
desc "Report code statistics (KLOCs, etc) from the application"
|
@@ -119,8 +119,11 @@ task :clone_structure_to_test => [ :db_structure_dump, :purge_test_database ] do
|
|
119
119
|
IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table|
|
120
120
|
ActiveRecord::Base.connection.execute(table)
|
121
121
|
end
|
122
|
-
when
|
123
|
-
|
122
|
+
when "postgresql"
|
123
|
+
ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
|
124
|
+
ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
|
125
|
+
ENV['PGPASSWORD'] = abcs["test"]["password"]
|
126
|
+
`psql -U "#{abcs["test"]["username"]}" -f db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}`
|
124
127
|
when "sqlite", "sqlite3"
|
125
128
|
`#{abcs[RAILS_ENV]["adapter"]} #{abcs["test"]["dbfile"]} < db/#{RAILS_ENV}_structure.sql`
|
126
129
|
else
|
@@ -135,8 +138,11 @@ task :db_structure_dump => :environment do
|
|
135
138
|
when "mysql"
|
136
139
|
ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
|
137
140
|
File.open("db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
|
138
|
-
when
|
139
|
-
|
141
|
+
when "postgresql"
|
142
|
+
ENV['PGHOST'] = abcs[RAILS_ENV]["host"] if abcs[RAILS_ENV]["host"]
|
143
|
+
ENV['PGPORT'] = abcs[RAILS_ENV]["port"].to_s if abcs[RAILS_ENV]["port"]
|
144
|
+
ENV['PGPASSWORD'] = abcs[RAILS_ENV]["password"]
|
145
|
+
`pg_dump -U "#{abcs[RAILS_ENV]["username"]}" -s -x -f db/#{RAILS_ENV}_structure.sql #{abcs[RAILS_ENV]["database"]}`
|
140
146
|
when "sqlite", "sqlite3"
|
141
147
|
`#{abcs[RAILS_ENV]["adapter"]} #{abcs[RAILS_ENV]["dbfile"]} .schema > db/#{RAILS_ENV}_structure.sql`
|
142
148
|
else
|
@@ -152,8 +158,11 @@ task :purge_test_database => :environment do
|
|
152
158
|
ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
|
153
159
|
ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"])
|
154
160
|
when "postgresql"
|
155
|
-
|
156
|
-
|
161
|
+
ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
|
162
|
+
ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
|
163
|
+
ENV['PGPASSWORD'] = abcs["test"]["password"]
|
164
|
+
`dropdb -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
|
165
|
+
`createdb -T template0 -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
|
157
166
|
when "sqlite","sqlite3"
|
158
167
|
File.delete(abcs["test"]["dbfile"]) if File.exist?(abcs["test"]["dbfile"])
|
159
168
|
else
|
@@ -0,0 +1,336 @@
|
|
1
|
+
/* Prototype: an object-oriented Javascript library, version 1.0.1
|
2
|
+
* (c) 2005 Sam Stephenson <sam@conio.net>
|
3
|
+
*
|
4
|
+
* Prototype is freely distributable under the terms of an MIT-style license.
|
5
|
+
* For details, see http://prototype.conio.net/
|
6
|
+
*/
|
7
|
+
|
8
|
+
Prototype = {
|
9
|
+
Version: '1.0.1'
|
10
|
+
}
|
11
|
+
|
12
|
+
Class = {
|
13
|
+
create: function() {
|
14
|
+
return function() {
|
15
|
+
this.initialize.apply(this, arguments);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
Abstract = new Object();
|
21
|
+
|
22
|
+
Object.prototype.extend = function(object) {
|
23
|
+
for (property in object) {
|
24
|
+
this[property] = object[property];
|
25
|
+
}
|
26
|
+
return this;
|
27
|
+
}
|
28
|
+
|
29
|
+
Function.prototype.bind = function(object) {
|
30
|
+
var method = this;
|
31
|
+
return function() {
|
32
|
+
method.apply(object, arguments);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
Function.prototype.bindAsEventListener = function(object) {
|
37
|
+
var method = this;
|
38
|
+
return function(event) {
|
39
|
+
method.call(object, event || window.event);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
Try = {
|
44
|
+
these: function() {
|
45
|
+
var returnValue;
|
46
|
+
|
47
|
+
for (var i = 0; i < arguments.length; i++) {
|
48
|
+
var lambda = arguments[i];
|
49
|
+
try {
|
50
|
+
returnValue = lambda();
|
51
|
+
break;
|
52
|
+
} catch (e) {}
|
53
|
+
}
|
54
|
+
|
55
|
+
return returnValue;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
|
59
|
+
Toggle = {
|
60
|
+
display: function() {
|
61
|
+
for (var i = 0; i < elements.length; i++) {
|
62
|
+
var element = $(elements[i]);
|
63
|
+
element.style.display =
|
64
|
+
(element.style.display == 'none' ? '' : 'none');
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
/*--------------------------------------------------------------------------*/
|
70
|
+
|
71
|
+
function $() {
|
72
|
+
var elements = new Array();
|
73
|
+
|
74
|
+
for (var i = 0; i < arguments.length; i++) {
|
75
|
+
var element = arguments[i];
|
76
|
+
if (typeof element == 'string')
|
77
|
+
element = document.getElementById(element);
|
78
|
+
|
79
|
+
if (arguments.length == 1)
|
80
|
+
return element;
|
81
|
+
|
82
|
+
elements.push(element);
|
83
|
+
}
|
84
|
+
|
85
|
+
return elements;
|
86
|
+
}
|
87
|
+
|
88
|
+
function getElementsByClassName(className, element) {
|
89
|
+
var children = (element || document).getElementsByTagName('*');
|
90
|
+
var elements = new Array();
|
91
|
+
|
92
|
+
for (var i = 0; i < children.length; i++) {
|
93
|
+
var child = children[i];
|
94
|
+
var classNames = child.className.split(' ');
|
95
|
+
for (var j = 0; j < classNames.length; j++) {
|
96
|
+
if (classNames[j] == className) {
|
97
|
+
elements.push(child);
|
98
|
+
break;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
return elements;
|
104
|
+
}
|
105
|
+
|
106
|
+
/*--------------------------------------------------------------------------*/
|
107
|
+
|
108
|
+
Ajax = {
|
109
|
+
getTransport: function() {
|
110
|
+
return Try.these(
|
111
|
+
function() {return new ActiveXObject('Msxml2.XMLHTTP')},
|
112
|
+
function() {return new ActiveXObject('Microsoft.XMLHTTP')},
|
113
|
+
function() {return new XMLHttpRequest()}
|
114
|
+
) || false;
|
115
|
+
},
|
116
|
+
|
117
|
+
emptyFunction: function() {}
|
118
|
+
}
|
119
|
+
|
120
|
+
Ajax.Base = function() {};
|
121
|
+
Ajax.Base.prototype = {
|
122
|
+
setOptions: function(options) {
|
123
|
+
this.options = {
|
124
|
+
method: 'post',
|
125
|
+
asynchronous: true,
|
126
|
+
parameters: ''
|
127
|
+
}.extend(options || {});
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
Ajax.Request = Class.create();
|
132
|
+
Ajax.Request.Events =
|
133
|
+
['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete'];
|
134
|
+
|
135
|
+
Ajax.Request.prototype = (new Ajax.Base()).extend({
|
136
|
+
initialize: function(url, options) {
|
137
|
+
this.transport = Ajax.getTransport();
|
138
|
+
this.setOptions(options);
|
139
|
+
|
140
|
+
try {
|
141
|
+
if (this.options.method == 'get')
|
142
|
+
url += '?' + this.options.parameters + '&_=';
|
143
|
+
|
144
|
+
this.transport.open(this.options.method, url, true);
|
145
|
+
|
146
|
+
if (this.options.asynchronous) {
|
147
|
+
this.transport.onreadystatechange = this.onStateChange.bind(this);
|
148
|
+
setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10);
|
149
|
+
}
|
150
|
+
|
151
|
+
if (this.options.method == 'post') {
|
152
|
+
this.transport.setRequestHeader('Connection', 'close');
|
153
|
+
this.transport.setRequestHeader('Content-type',
|
154
|
+
'application/x-www-form-urlencoded');
|
155
|
+
}
|
156
|
+
|
157
|
+
this.transport.send(this.options.method == 'post' ?
|
158
|
+
this.options.parameters + '&_=' : null);
|
159
|
+
|
160
|
+
} catch (e) {
|
161
|
+
}
|
162
|
+
},
|
163
|
+
|
164
|
+
onStateChange: function() {
|
165
|
+
var readyState = this.transport.readyState;
|
166
|
+
if (readyState != 1)
|
167
|
+
this.respondToReadyState(this.transport.readyState);
|
168
|
+
},
|
169
|
+
|
170
|
+
respondToReadyState: function(readyState) {
|
171
|
+
var event = Ajax.Request.Events[readyState];
|
172
|
+
(this.options['on' + event] || Ajax.emptyFunction)(this.transport);
|
173
|
+
}
|
174
|
+
});
|
175
|
+
|
176
|
+
Ajax.Updater = Class.create();
|
177
|
+
Ajax.Updater.prototype = (new Ajax.Base()).extend({
|
178
|
+
initialize: function(container, url, options) {
|
179
|
+
this.container = $(container);
|
180
|
+
this.setOptions(options);
|
181
|
+
|
182
|
+
if (this.options.asynchronous) {
|
183
|
+
this.onComplete = this.options.onComplete;
|
184
|
+
this.options.onComplete = this.updateContent.bind(this);
|
185
|
+
}
|
186
|
+
|
187
|
+
this.request = new Ajax.Request(url, this.options);
|
188
|
+
|
189
|
+
if (!this.options.asynchronous)
|
190
|
+
this.updateContent();
|
191
|
+
},
|
192
|
+
|
193
|
+
updateContent: function() {
|
194
|
+
this.container.innerHTML = this.request.transport.responseText;
|
195
|
+
if (this.onComplete) this.onComplete(this.request);
|
196
|
+
}
|
197
|
+
});
|
198
|
+
|
199
|
+
/*--------------------------------------------------------------------------*/
|
200
|
+
|
201
|
+
Field = {
|
202
|
+
clear: function() {
|
203
|
+
for (var i = 0; i < arguments.length; i++)
|
204
|
+
$(arguments[i]).value = '';
|
205
|
+
},
|
206
|
+
|
207
|
+
focus: function(element) {
|
208
|
+
$(element).focus();
|
209
|
+
},
|
210
|
+
|
211
|
+
present: function() {
|
212
|
+
for (var i = 0; i < arguments.length; i++)
|
213
|
+
if ($(arguments[i]).value == '') return false;
|
214
|
+
return true;
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
/*--------------------------------------------------------------------------*/
|
219
|
+
|
220
|
+
Form = {
|
221
|
+
serialize: function(form) {
|
222
|
+
var elements = Form.getElements($(form));
|
223
|
+
var queryComponents = new Array();
|
224
|
+
|
225
|
+
for (var i = 0; i < elements.length; i++) {
|
226
|
+
var queryComponent = Form.Element.serialize(elements[i]);
|
227
|
+
if (queryComponent)
|
228
|
+
queryComponents.push(queryComponent);
|
229
|
+
}
|
230
|
+
|
231
|
+
return queryComponents.join('&');
|
232
|
+
},
|
233
|
+
|
234
|
+
getElements: function(form) {
|
235
|
+
form = $(form);
|
236
|
+
var elements = new Array();
|
237
|
+
|
238
|
+
for (tagName in Form.Element.Serializers) {
|
239
|
+
var tagElements = form.getElementsByTagName(tagName);
|
240
|
+
for (var j = 0; j < tagElements.length; j++)
|
241
|
+
elements.push(tagElements[j]);
|
242
|
+
}
|
243
|
+
return elements;
|
244
|
+
}
|
245
|
+
}
|
246
|
+
|
247
|
+
Form.Element = {
|
248
|
+
serialize: function(element) {
|
249
|
+
element = $(element);
|
250
|
+
var method = element.tagName.toLowerCase();
|
251
|
+
var parameter = Form.Element.Serializers[method](element);
|
252
|
+
|
253
|
+
if (parameter)
|
254
|
+
return encodeURIComponent(parameter[0]) + '=' +
|
255
|
+
encodeURIComponent(parameter[1]);
|
256
|
+
},
|
257
|
+
|
258
|
+
getValue: function(element) {
|
259
|
+
element = $(element);
|
260
|
+
var method = element.tagName.toLowerCase();
|
261
|
+
var parameter = Form.Element.Serializers[method](element);
|
262
|
+
|
263
|
+
if (parameter)
|
264
|
+
return parameter[1];
|
265
|
+
}
|
266
|
+
}
|
267
|
+
|
268
|
+
Form.Element.Serializers = {
|
269
|
+
input: function(element) {
|
270
|
+
switch (element.type.toLowerCase()) {
|
271
|
+
case 'hidden':
|
272
|
+
case 'text':
|
273
|
+
return Form.Element.Serializers.textarea(element);
|
274
|
+
case 'checkbox':
|
275
|
+
case 'radio':
|
276
|
+
return Form.Element.Serializers.inputSelector(element);
|
277
|
+
}
|
278
|
+
},
|
279
|
+
|
280
|
+
inputSelector: function(element) {
|
281
|
+
if (element.checked)
|
282
|
+
return [element.name, element.value];
|
283
|
+
},
|
284
|
+
|
285
|
+
textarea: function(element) {
|
286
|
+
return [element.name, element.value];
|
287
|
+
},
|
288
|
+
|
289
|
+
select: function(element) {
|
290
|
+
var index = element.selectedIndex;
|
291
|
+
return [element.name, (index >= 0) ? element.options[index].value : ''];
|
292
|
+
}
|
293
|
+
}
|
294
|
+
|
295
|
+
/*--------------------------------------------------------------------------*/
|
296
|
+
|
297
|
+
Abstract.TimedObserver = function() {}
|
298
|
+
Abstract.TimedObserver.prototype = {
|
299
|
+
initialize: function(element, frequency, callback) {
|
300
|
+
this.frequency = frequency;
|
301
|
+
this.element = $(element);
|
302
|
+
this.callback = callback;
|
303
|
+
|
304
|
+
this.lastValue = this.getValue();
|
305
|
+
this.registerCallback();
|
306
|
+
},
|
307
|
+
|
308
|
+
registerCallback: function() {
|
309
|
+
setTimeout(this.onTimerEvent.bind(this), this.frequency * 1000);
|
310
|
+
},
|
311
|
+
|
312
|
+
onTimerEvent: function() {
|
313
|
+
var value = this.getValue();
|
314
|
+
if (this.lastValue != value) {
|
315
|
+
this.callback(this.element, value);
|
316
|
+
this.lastValue = value;
|
317
|
+
}
|
318
|
+
|
319
|
+
this.registerCallback();
|
320
|
+
}
|
321
|
+
}
|
322
|
+
|
323
|
+
Form.Element.Observer = Class.create();
|
324
|
+
Form.Element.Observer.prototype = (new Abstract.TimedObserver()).extend({
|
325
|
+
getValue: function() {
|
326
|
+
return Form.Element.getValue(this.element);
|
327
|
+
}
|
328
|
+
});
|
329
|
+
|
330
|
+
Form.Observer = Class.create();
|
331
|
+
Form.Observer.prototype = (new Abstract.TimedObserver()).extend({
|
332
|
+
getValue: function() {
|
333
|
+
return Form.serialize(this.element);
|
334
|
+
}
|
335
|
+
});
|
336
|
+
|
@@ -37,17 +37,13 @@ class AppGenerator < Rails::Generator::Base
|
|
37
37
|
m.template "configs/apache.conf", "public/.htaccess"
|
38
38
|
|
39
39
|
# Environments
|
40
|
-
|
41
|
-
m.file "environments/shared_for_gem.rb", "config/environment.rb"
|
42
|
-
else
|
43
|
-
m.file "environments/shared.rb", "config/environment.rb"
|
44
|
-
end
|
40
|
+
m.file "environments/environment.rb", "config/environment.rb"
|
45
41
|
m.file "environments/production.rb", "config/environments/production.rb"
|
46
42
|
m.file "environments/development.rb", "config/environments/development.rb"
|
47
43
|
m.file "environments/test.rb", "config/environments/test.rb"
|
48
44
|
|
49
45
|
# Scripts
|
50
|
-
%w(console console_sandbox.rb destroy generate server).each do |file|
|
46
|
+
%w(console console_sandbox.rb destroy generate server runner).each do |file|
|
51
47
|
m.file "bin/#{file}", "script/#{file}", script_options
|
52
48
|
end
|
53
49
|
if options[:gem]
|
@@ -68,6 +64,9 @@ class AppGenerator < Rails::Generator::Base
|
|
68
64
|
|
69
65
|
m.template "html/favicon.ico", "public/favicon.ico"
|
70
66
|
|
67
|
+
# Javascripts
|
68
|
+
m.file "html/javascripts/prototype.js", "public/javascripts/prototype.js"
|
69
|
+
|
71
70
|
# Docs
|
72
71
|
m.file "doc/README_FOR_APP", "doc/README_FOR_APP"
|
73
72
|
|
@@ -5,7 +5,7 @@ Description:
|
|
5
5
|
given in CamelCase or under_score and should not be suffixed with 'Model'.
|
6
6
|
|
7
7
|
The generator creates a model class in app/models, a test suite in
|
8
|
-
test/unit, and test fixtures in test/fixtures/
|
8
|
+
test/unit, and test fixtures in test/fixtures/singular_name.yml.
|
9
9
|
|
10
10
|
Example:
|
11
11
|
./script/generate model Account
|
@@ -6,6 +6,11 @@ class ScaffoldingSandbox
|
|
6
6
|
def sandbox_binding
|
7
7
|
binding
|
8
8
|
end
|
9
|
+
|
10
|
+
def default_input_block
|
11
|
+
Proc.new { |record, column| "<p><label for=\"#{record}_#{column.name}\">#{column.human_name}</label><br/>\n#{input(record, column.name)}</p>\n" }
|
12
|
+
end
|
13
|
+
|
9
14
|
end
|
10
15
|
|
11
16
|
class ActionView::Helpers::InstanceTag
|
@@ -54,7 +59,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
|
|
54
59
|
def manifest
|
55
60
|
record do |m|
|
56
61
|
# Depend on model generator but skip if the model exists.
|
57
|
-
m.dependency 'model', [
|
62
|
+
m.dependency 'model', [singular_name], :collision => :skip
|
58
63
|
|
59
64
|
# Check for class naming collisions.
|
60
65
|
m.class_collisions controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}ControllerTest", "#{controller_class_name}Helper"
|
@@ -97,19 +102,16 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
|
|
97
102
|
end
|
98
103
|
|
99
104
|
# Scaffolded forms.
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
:end_mark => 'eoform',
|
111
|
-
:mark_id => singular_name
|
112
|
-
end
|
105
|
+
m.complex_template "form.rhtml",
|
106
|
+
File.join('app/views',
|
107
|
+
controller_class_path,
|
108
|
+
controller_file_name,
|
109
|
+
"_form.rhtml"),
|
110
|
+
:insert => 'form_scaffolding.rhtml',
|
111
|
+
:sandbox => lambda { create_sandbox },
|
112
|
+
:begin_mark => 'form',
|
113
|
+
:end_mark => 'eoform',
|
114
|
+
:mark_id => singular_name
|
113
115
|
|
114
116
|
# Unscaffolded views.
|
115
117
|
unscaffolded_actions.each do |action|
|
@@ -130,16 +132,16 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
|
|
130
132
|
end
|
131
133
|
|
132
134
|
def scaffold_views
|
133
|
-
%w(list show)
|
134
|
-
end
|
135
|
-
|
136
|
-
def scaffold_forms
|
137
|
-
%w(new edit)
|
135
|
+
%w(list show new edit)
|
138
136
|
end
|
139
137
|
|
140
138
|
def scaffold_actions
|
141
139
|
scaffold_views + %w(index create update destroy)
|
142
140
|
end
|
141
|
+
|
142
|
+
def model_name
|
143
|
+
class_name.demodulize
|
144
|
+
end
|
143
145
|
|
144
146
|
def unscaffolded_actions
|
145
147
|
args - scaffold_actions
|
@@ -149,10 +151,8 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
|
|
149
151
|
"_#{singular_name}" if options[:suffix]
|
150
152
|
end
|
151
153
|
|
152
|
-
def create_sandbox
|
154
|
+
def create_sandbox
|
153
155
|
sandbox = ScaffoldingSandbox.new
|
154
|
-
action = if action == 'edit' then 'update' else 'create' end
|
155
|
-
sandbox.form_action = action
|
156
156
|
sandbox.singular_name = singular_name
|
157
157
|
begin
|
158
158
|
sandbox.model_instance = model_instance
|
@@ -164,7 +164,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
|
|
164
164
|
sandbox.suffix = suffix
|
165
165
|
sandbox
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
def model_instance
|
169
169
|
base = class_nesting.split('::').inject(Object) do |base, nested|
|
170
170
|
break base.const_get(nested) if base.const_defined?(nested)
|
@@ -12,21 +12,21 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
12
12
|
|
13
13
|
<% end -%>
|
14
14
|
def list<%= suffix %>
|
15
|
-
@<%= plural_name %> = <%=
|
15
|
+
@<%= plural_name %> = <%= model_name %>.find_all
|
16
16
|
end
|
17
17
|
|
18
18
|
def show<%= suffix %>
|
19
|
-
@<%= singular_name %> = <%=
|
19
|
+
@<%= singular_name %> = <%= model_name %>.find(@params[:id])
|
20
20
|
end
|
21
21
|
|
22
22
|
def new<%= suffix %>
|
23
|
-
@<%= singular_name %> = <%=
|
23
|
+
@<%= singular_name %> = <%= model_name %>.new
|
24
24
|
end
|
25
25
|
|
26
26
|
def create<%= suffix %>
|
27
|
-
@<%= singular_name %> = <%=
|
27
|
+
@<%= singular_name %> = <%= model_name %>.new(@params[:<%= singular_name %>])
|
28
28
|
if @<%= singular_name %>.save
|
29
|
-
flash['notice'] = '<%=
|
29
|
+
flash['notice'] = '<%= model_name %> was successfully created.'
|
30
30
|
redirect_to :action => 'list<%= suffix %>'
|
31
31
|
else
|
32
32
|
render_action 'new<%= suffix %>'
|
@@ -34,21 +34,21 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def edit<%= suffix %>
|
37
|
-
@<%= singular_name %> = <%=
|
37
|
+
@<%= singular_name %> = <%= model_name %>.find(@params[:id])
|
38
38
|
end
|
39
39
|
|
40
40
|
def update
|
41
|
-
@<%= singular_name %> = <%=
|
42
|
-
if @<%= singular_name %>.update_attributes(@params[
|
43
|
-
flash['notice'] = '<%=
|
44
|
-
redirect_to :action => 'show<%= suffix %>', :id => @<%= singular_name
|
41
|
+
@<%= singular_name %> = <%= model_name %>.find(@params[:id])
|
42
|
+
if @<%= singular_name %>.update_attributes(@params[:<%= singular_name %>])
|
43
|
+
flash['notice'] = '<%= model_name %> was successfully updated.'
|
44
|
+
redirect_to :action => 'show<%= suffix %>', :id => @<%= singular_name %>
|
45
45
|
else
|
46
46
|
render_action 'edit<%= suffix %>'
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
def destroy<%= suffix %>
|
51
|
-
<%=
|
51
|
+
<%= model_name %>.find(@params[:id]).destroy
|
52
52
|
redirect_to :action => 'list<%= suffix %>'
|
53
53
|
end
|
54
54
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
<%%=
|
2
|
-
|
3
|
-
<%=
|
4
|
-
<input type="submit" value="<%= @form_action.to_s.capitalize %>" />
|
5
|
-
<%%= end_form_tag %>
|
1
|
+
<%%= error_messages_for '<%= singular_name %>' %>
|
2
|
+
|
3
|
+
<%= template_for_inclusion %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= all_input_tags(@model_instance, @singular_name, {}) %>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__) + '<%=
|
1
|
+
require File.dirname(__FILE__) + '<%= "/.." * controller_class_nesting_depth %>/../test_helper'
|
2
2
|
require '<%= controller_file_path %>_controller'
|
3
3
|
|
4
4
|
# Re-raise errors caught by the controller.
|
@@ -15,66 +15,66 @@ class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
|
|
15
15
|
|
16
16
|
<% for action in unscaffolded_actions -%>
|
17
17
|
def test_<%= action %>
|
18
|
-
|
18
|
+
get :<%= action %>
|
19
19
|
assert_rendered_file '<%= action %>'
|
20
20
|
end
|
21
21
|
|
22
22
|
<% end -%>
|
23
23
|
<% unless suffix -%>
|
24
24
|
def test_index
|
25
|
-
|
25
|
+
get :index
|
26
26
|
assert_rendered_file 'list'
|
27
27
|
end
|
28
28
|
|
29
29
|
<% end -%>
|
30
30
|
def test_list<%= suffix %>
|
31
|
-
|
31
|
+
get :list<%= suffix %>
|
32
32
|
assert_rendered_file 'list<%= suffix %>'
|
33
33
|
assert_template_has '<%= plural_name %>'
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_show<%= suffix %>
|
37
|
-
|
37
|
+
get :show<%= suffix %>, 'id' => 1
|
38
38
|
assert_rendered_file 'show'
|
39
39
|
assert_template_has '<%= singular_name %>'
|
40
40
|
assert_valid_record '<%= singular_name %>'
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_new<%= suffix %>
|
44
|
-
|
44
|
+
get :new<%= suffix %>
|
45
45
|
assert_rendered_file 'new<%= suffix %>'
|
46
46
|
assert_template_has '<%= singular_name %>'
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_create
|
50
|
-
num_<%= plural_name %> = <%=
|
50
|
+
num_<%= plural_name %> = <%= model_name %>.find_all.size
|
51
51
|
|
52
|
-
|
52
|
+
post :create<%= suffix %>, '<%= singular_name %>' => { }
|
53
53
|
assert_redirected_to :action => 'list<%= suffix %>'
|
54
54
|
|
55
|
-
assert_equal num_<%= plural_name %> + 1, <%=
|
55
|
+
assert_equal num_<%= plural_name %> + 1, <%= model_name %>.find_all.size
|
56
56
|
end
|
57
57
|
|
58
58
|
def test_edit<%= suffix %>
|
59
|
-
|
59
|
+
get :edit<%= suffix %>, 'id' => 1
|
60
60
|
assert_rendered_file 'edit<%= suffix %>'
|
61
61
|
assert_template_has '<%= singular_name %>'
|
62
62
|
assert_valid_record '<%= singular_name %>'
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_update<%= suffix %>
|
66
|
-
|
66
|
+
post :update<%= suffix %>, 'id' => 1
|
67
67
|
assert_redirected_to :action => 'show<%= suffix %>', :id => 1
|
68
68
|
end
|
69
69
|
|
70
70
|
def test_destroy<%= suffix %>
|
71
|
-
assert_not_nil <%=
|
71
|
+
assert_not_nil <%= model_name %>.find(1)
|
72
72
|
|
73
|
-
|
73
|
+
post :destroy, 'id' => 1
|
74
74
|
assert_redirected_to :action => 'list<%= suffix %>'
|
75
75
|
|
76
76
|
assert_raise(ActiveRecord::RecordNotFound) {
|
77
|
-
<%= singular_name %> = <%=
|
77
|
+
<%= singular_name %> = <%= model_name %>.find(1)
|
78
78
|
}
|
79
79
|
end
|
80
80
|
end
|
@@ -1,7 +1,9 @@
|
|
1
1
|
<h1>Editing <%= singular_name %></h1>
|
2
2
|
|
3
|
-
<%%=
|
4
|
-
|
3
|
+
<%%= start_form_tag :action => 'update<%= @suffix %>', :id => @<%= singular_name %> %>
|
4
|
+
<%%= render_partial "form" %>
|
5
|
+
<%%= submit_tag "Edit" %>
|
6
|
+
<%%= end_form_tag %>
|
5
7
|
|
6
|
-
<%%= link_to 'Show', :action => 'show<%= suffix %>', :id => @<%= singular_name
|
8
|
+
<%%= link_to 'Show', :action => 'show<%= suffix %>', :id => @<%= singular_name %> %> |
|
7
9
|
<%%= link_to 'Back', :action => 'list<%= suffix %>' %>
|
@@ -2,19 +2,19 @@
|
|
2
2
|
|
3
3
|
<table>
|
4
4
|
<tr>
|
5
|
-
<%% for column in <%=
|
5
|
+
<%% for column in <%= model_name %>.content_columns %>
|
6
6
|
<th><%%= column.human_name %></th>
|
7
7
|
<%% end %>
|
8
8
|
</tr>
|
9
9
|
|
10
10
|
<%% for <%= singular_name %> in @<%= plural_name %> %>
|
11
11
|
<tr>
|
12
|
-
<%% for column in <%=
|
12
|
+
<%% for column in <%= model_name %>.content_columns %>
|
13
13
|
<td><%%=h <%= singular_name %>.send(column.name) %></td>
|
14
14
|
<%% end %>
|
15
|
-
<td><%%= link_to 'Show', :action => 'show<%= suffix %>', :id => <%= singular_name
|
16
|
-
<td><%%= link_to 'Edit', :action => 'edit<%= suffix %>', :id => <%= singular_name
|
17
|
-
<td><%%= link_to 'Destroy', :action => 'destroy<%= suffix %>', :id => <%= singular_name
|
15
|
+
<td><%%= link_to 'Show', :action => 'show<%= suffix %>', :id => <%= singular_name %> %></td>
|
16
|
+
<td><%%= link_to 'Edit', :action => 'edit<%= suffix %>', :id => <%= singular_name %> %></td>
|
17
|
+
<td><%%= link_to 'Destroy', {:action => 'destroy<%= suffix %>', :id => <%= singular_name %>}, :confirm => "Are you sure?" %></td>
|
18
18
|
</tr>
|
19
19
|
<%% end %>
|
20
20
|
</table>
|
@@ -1,6 +1,8 @@
|
|
1
1
|
<h1>New <%= singular_name %></h1>
|
2
2
|
|
3
|
-
<%%=
|
4
|
-
|
3
|
+
<%%= start_form_tag :action => 'create<%= @suffix %>' %>
|
4
|
+
<%%= render_partial "form" %>
|
5
|
+
<%%= submit_tag "Create" %>
|
6
|
+
<%%= end_form_tag %>
|
5
7
|
|
6
8
|
<%%= link_to 'Back', :action => 'list<%= suffix %>' %>
|
@@ -1,8 +1,8 @@
|
|
1
|
-
<%% for column in <%=
|
1
|
+
<%% for column in <%= model_name %>.content_columns %>
|
2
2
|
<p>
|
3
|
-
<b><%%= column.human_name %>:</b> <%%= @<%= singular_name %>.send(column.name) %>
|
3
|
+
<b><%%= column.human_name %>:</b> <%%=h @<%= singular_name %>.send(column.name) %>
|
4
4
|
</p>
|
5
5
|
<%% end %>
|
6
6
|
|
7
|
-
<%%= link_to 'Edit', :action => 'edit<%= suffix %>', :id => @<%= singular_name
|
7
|
+
<%%= link_to 'Edit', :action => 'edit<%= suffix %>', :id => @<%= singular_name %> %> |
|
8
8
|
<%%= link_to 'Back', :action => 'list<%= suffix %>' %>
|
data/lib/webrick_server.rb
CHANGED
@@ -69,6 +69,7 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
|
|
69
69
|
|
70
70
|
def handle_dispatch(req, res, origin = nil)
|
71
71
|
env = req.meta_vars.clone
|
72
|
+
env.delete "SCRIPT_NAME"
|
72
73
|
env["QUERY_STRING"] = req.request_uri.query
|
73
74
|
env["REQUEST_URI"] = origin if origin
|
74
75
|
|
@@ -94,6 +95,7 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet
|
|
94
95
|
res.status = $1.to_i
|
95
96
|
header.delete('status')
|
96
97
|
end
|
98
|
+
res.cookies.concat header.delete('set-cookie')
|
97
99
|
header.each { |key, val| res[key] = val.join(", ") }
|
98
100
|
|
99
101
|
res.body = body
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.8
|
3
3
|
specification_version: 1
|
4
4
|
name: rails
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2005-03-
|
6
|
+
version: 0.11.0
|
7
|
+
date: 2005-03-22
|
8
8
|
summary: "Web-application framework with template engine, control-flow layer, and ORM."
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- bin/destroy
|
52
52
|
- bin/generate
|
53
53
|
- bin/rails
|
54
|
+
- bin/runner
|
54
55
|
- bin/server
|
55
56
|
- bin/update
|
56
57
|
- configs/apache.conf
|
@@ -61,9 +62,8 @@ files:
|
|
61
62
|
- dispatches/dispatch.fcgi
|
62
63
|
- dispatches/dispatch.rb
|
63
64
|
- environments/development.rb
|
65
|
+
- environments/environment.rb
|
64
66
|
- environments/production.rb
|
65
|
-
- environments/shared.rb
|
66
|
-
- environments/shared_for_gem.rb
|
67
67
|
- environments/test.rb
|
68
68
|
- helpers/application.rb
|
69
69
|
- helpers/application_helper.rb
|
@@ -72,6 +72,8 @@ files:
|
|
72
72
|
- html/500.html
|
73
73
|
- html/favicon.ico
|
74
74
|
- html/index.html
|
75
|
+
- html/javascripts
|
76
|
+
- html/javascripts/prototype.js
|
75
77
|
- lib/binding_of_caller.rb
|
76
78
|
- lib/breakpoint.rb
|
77
79
|
- lib/breakpoint_client.rb
|
@@ -125,6 +127,7 @@ files:
|
|
125
127
|
- lib/rails_generator/generators/components/scaffold/USAGE
|
126
128
|
- lib/rails_generator/generators/components/scaffold/templates/controller.rb
|
127
129
|
- lib/rails_generator/generators/components/scaffold/templates/form.rhtml
|
130
|
+
- lib/rails_generator/generators/components/scaffold/templates/form_scaffolding.rhtml
|
128
131
|
- lib/rails_generator/generators/components/scaffold/templates/functional_test.rb
|
129
132
|
- lib/rails_generator/generators/components/scaffold/templates/helper.rb
|
130
133
|
- lib/rails_generator/generators/components/scaffold/templates/layout.rhtml
|
@@ -170,7 +173,7 @@ dependencies:
|
|
170
173
|
-
|
171
174
|
- "="
|
172
175
|
- !ruby/object:Gem::Version
|
173
|
-
version: 1.0.
|
176
|
+
version: 1.0.2
|
174
177
|
version:
|
175
178
|
- !ruby/object:Gem::Dependency
|
176
179
|
name: activerecord
|
@@ -180,7 +183,7 @@ dependencies:
|
|
180
183
|
-
|
181
184
|
- "="
|
182
185
|
- !ruby/object:Gem::Version
|
183
|
-
version: 1.
|
186
|
+
version: 1.9.0
|
184
187
|
version:
|
185
188
|
- !ruby/object:Gem::Dependency
|
186
189
|
name: actionpack
|
@@ -190,7 +193,7 @@ dependencies:
|
|
190
193
|
-
|
191
194
|
- "="
|
192
195
|
- !ruby/object:Gem::Version
|
193
|
-
version: 1.
|
196
|
+
version: 1.6.0
|
194
197
|
version:
|
195
198
|
- !ruby/object:Gem::Dependency
|
196
199
|
name: actionmailer
|
@@ -200,7 +203,7 @@ dependencies:
|
|
200
203
|
-
|
201
204
|
- "="
|
202
205
|
- !ruby/object:Gem::Version
|
203
|
-
version: 0.
|
206
|
+
version: 0.8.0
|
204
207
|
version:
|
205
208
|
- !ruby/object:Gem::Dependency
|
206
209
|
name: actionwebservice
|
@@ -210,5 +213,5 @@ dependencies:
|
|
210
213
|
-
|
211
214
|
- "="
|
212
215
|
- !ruby/object:Gem::Version
|
213
|
-
version: 0.6.
|
216
|
+
version: 0.6.1
|
214
217
|
version:
|
@@ -1,66 +0,0 @@
|
|
1
|
-
RAILS_ROOT = File.dirname(__FILE__) + "/../"
|
2
|
-
RAILS_ENV = ENV['RAILS_ENV'] || 'development'
|
3
|
-
|
4
|
-
|
5
|
-
# Mocks first.
|
6
|
-
ADDITIONAL_LOAD_PATHS = ["#{RAILS_ROOT}/test/mocks/#{RAILS_ENV}"]
|
7
|
-
|
8
|
-
# Then model subdirectories.
|
9
|
-
ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/app/models/[_a-z]*"])
|
10
|
-
ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/components/[_a-z]*"])
|
11
|
-
|
12
|
-
# Followed by the standard includes.
|
13
|
-
ADDITIONAL_LOAD_PATHS.concat %w(
|
14
|
-
app
|
15
|
-
app/models
|
16
|
-
app/controllers
|
17
|
-
app/helpers
|
18
|
-
app/apis
|
19
|
-
config
|
20
|
-
components
|
21
|
-
lib
|
22
|
-
vendor
|
23
|
-
).map { |dir| "#{RAILS_ROOT}/#{dir}" }
|
24
|
-
|
25
|
-
# Prepend to $LOAD_PATH
|
26
|
-
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
|
27
|
-
|
28
|
-
|
29
|
-
# Require Rails gems.
|
30
|
-
require 'rubygems'
|
31
|
-
require_gem 'activesupport'
|
32
|
-
require_gem 'activerecord'
|
33
|
-
require_gem 'actionpack'
|
34
|
-
require_gem 'actionmailer'
|
35
|
-
require_gem 'actionwebservice'
|
36
|
-
require_gem 'rails'
|
37
|
-
|
38
|
-
|
39
|
-
# Environment-specific configuration.
|
40
|
-
require_dependency "environments/#{RAILS_ENV}"
|
41
|
-
ActiveRecord::Base.configurations = YAML::load(File.open("#{RAILS_ROOT}/config/database.yml"))
|
42
|
-
ActiveRecord::Base.establish_connection
|
43
|
-
|
44
|
-
|
45
|
-
# Configure defaults if the included environment did not.
|
46
|
-
begin
|
47
|
-
RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log")
|
48
|
-
rescue StandardError
|
49
|
-
RAILS_DEFAULT_LOGGER = Logger.new(STDERR)
|
50
|
-
RAILS_DEFAULT_LOGGER.level = Logger::WARN
|
51
|
-
RAILS_DEFAULT_LOGGER.warn(
|
52
|
-
"Rails Error: Unable to access log file. Please ensure that log/#{RAILS_ENV}.log exists and is chmod 0666. " +
|
53
|
-
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
|
54
|
-
)
|
55
|
-
end
|
56
|
-
|
57
|
-
[ActiveRecord, ActionController, ActionMailer].each { |mod| mod::Base.logger ||= RAILS_DEFAULT_LOGGER }
|
58
|
-
[ActionController, ActionMailer].each { |mod| mod::Base.template_root ||= "#{RAILS_ROOT}/app/views/" }
|
59
|
-
ActionController::Routing::Routes.reload
|
60
|
-
|
61
|
-
Controllers = Dependencies::LoadingModule.root(
|
62
|
-
File.join(RAILS_ROOT, 'app', 'controllers'),
|
63
|
-
File.join(RAILS_ROOT, 'components')
|
64
|
-
)
|
65
|
-
|
66
|
-
# Include your app's configuration here:
|