Skip to content

Commit d9d486e

Browse files
committed
updating depot from watirteach
1 parent d2fdb4f commit d9d486e

File tree

8 files changed

+530
-110
lines changed

8 files changed

+530
-110
lines changed

.project

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<projectDescription>
3-
<name>depot_demo</name>
3+
<name>framework-examples</name>
44
<comment></comment>
55
<projects>
66
</projects>
@@ -13,5 +13,6 @@
1313
</buildSpec>
1414
<natures>
1515
<nature>org.rubypeople.rdt.core.rubynature</nature>
16+
<nature>org.radrails.rails.core.railsnature</nature>
1617
</natures>
1718
</projectDescription>

depot/README.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
How to Run this Depot Application
22

3-
43
Install Rails
5-
1. "gem install rails -v 1.0 --include-dependencies"
4+
1. "gem install rails -v 1.0"
65

76
Install & Configure MySQL
8-
1. Install MySQL 4.1. Choose "Typical" Installation. Select the option to add
9-
commands to your path.
7+
1. Install MySQL 4.1 Essentials. Choose "Typical" Installation.
8+
Select the option to add commands to your path.
109
2. Configure MySQL with a "Standard Configuation" Server Instance.
1110

1211
Load Database

depot/config/boot.rb

+8-35
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,17 @@
1-
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb
2-
31
unless defined?(RAILS_ROOT)
42
root_path = File.join(File.dirname(__FILE__), '..')
5-
63
unless RUBY_PLATFORM =~ /mswin32/
74
require 'pathname'
8-
root_path = Pathname.new(root_path).cleanpath(true).to_s
5+
root_path = Pathname.new(root_path).cleanpath.to_s
96
end
10-
117
RAILS_ROOT = root_path
128
end
139

14-
unless defined?(Rails::Initializer)
15-
if File.directory?("#{RAILS_ROOT}/vendor/rails")
16-
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
17-
else
18-
require 'rubygems'
19-
20-
environment_without_comments = IO.readlines(File.dirname(__FILE__) + '/environment.rb').reject { |l| l =~ /^#/ }.join
21-
environment_without_comments =~ /[^#]RAILS_GEM_VERSION = '([\d.]+)'/
22-
rails_gem_version = $1
23-
24-
if version = defined?(RAILS_GEM_VERSION) ? RAILS_GEM_VERSION : rails_gem_version
25-
rails_gem = Gem.cache.search('rails', "=#{version}").first
26-
27-
if rails_gem
28-
require_gem "rails", "=#{version}"
29-
require rails_gem.full_gem_path + '/lib/initializer'
30-
else
31-
STDERR.puts %(Cannot find gem for Rails =#{version}:
32-
Install the missing gem with 'gem install -v=#{version} rails', or
33-
change environment.rb to define RAILS_GEM_VERSION with your desired version.
34-
)
35-
exit 1
36-
end
37-
else
38-
require_gem "rails"
39-
require 'initializer'
40-
end
41-
end
10+
if File.directory?("#{RAILS_ROOT}/vendor/rails")
11+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
12+
else
13+
require 'rubygems'
14+
require 'initializer'
15+
end
4216

43-
Rails::Initializer.run(:set_load_path)
44-
end
17+
Rails::Initializer.run(:set_load_path)

depot/config/database.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ development:
33
database: depot_development
44
host: localhost
55
username: root
6-
password: Trabajo
6+
password: password
77

88
test:
99
adapter: mysql
1010
database: depot_test
1111
host: localhost
12-
username:
13-
password:
12+
username: root
13+
password: password
1414

1515
production:
1616
adapter: mysql
1717
database: depot_development
1818
host: localhost
19-
username:
20-
password:
19+
username: root
20+
password: password

depot/config/environment.rb

+38-58
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,51 @@
1-
#---
2-
# Excerpted from "Agile Web Development with Rails"
3-
# We make no guarantees that this code is fit for any purpose.
4-
# Visit http://www.pragmaticprogrammer.com for more book information.
5-
#---
6-
RAILS_ROOT = File.dirname(__FILE__) + "/../"
7-
RAILS_ENV = ENV['RAILS_ENV'] || 'development'
1+
# Be sure to restart your webserver when you modify this file.
82

3+
# Uncomment below to force Rails into production mode
4+
# (Use only when you can't set environment variables through your web/app server)
5+
# ENV['RAILS_ENV'] = 'production'
96

10-
# Mocks first.
11-
ADDITIONAL_LOAD_PATHS = ["#{RAILS_ROOT}/test/mocks/#{RAILS_ENV}"]
7+
# Bootstrap the Rails environment, frameworks, and default configuration
8+
require File.join(File.dirname(__FILE__), 'boot')
129

13-
# Then model subdirectories.
14-
ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/app/models/[_a-z]*"])
15-
ADDITIONAL_LOAD_PATHS.concat(Dir["#{RAILS_ROOT}/components/[_a-z]*"])
10+
Rails::Initializer.run do |config|
11+
# Skip frameworks you're not going to use
12+
# config.frameworks -= [ :action_web_service, :action_mailer ]
1613

17-
# Followed by the standard includes.
18-
ADDITIONAL_LOAD_PATHS.concat %w(
19-
app
20-
app/models
21-
app/controllers
22-
app/helpers
23-
app/apis
24-
config
25-
components
26-
lib
27-
vendor
28-
).map { |dir| "#{RAILS_ROOT}/#{dir}" }
14+
# Add additional load paths for your own custom dirs
15+
# config.load_paths += %W( #{RAILS_ROOT}/app/services )
2916

30-
# Prepend to $LOAD_PATH
31-
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
17+
# Force all environments to use the same logger level
18+
# (by default production uses :info, the others :debug)
19+
# config.log_level = :debug
3220

21+
# Use the database for sessions instead of the file system
22+
# (create the session table with 'rake create_sessions_table')
23+
# config.action_controller.session_store = :active_record_store
3324

34-
# Require Rails gems.
35-
require 'rubygems'
36-
require_gem 'activesupport'
37-
require_gem 'activerecord'
38-
require_gem 'actionpack'
39-
require_gem 'actionmailer'
40-
require_gem 'actionwebservice'
41-
require_gem 'rails'
25+
# Enable page/fragment caching by setting a file-based store
26+
# (remember to create the caching directory and make it readable to the application)
27+
# config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache"
4228

29+
# Activate observers that should always be running
30+
# config.active_record.observers = :cacher, :garbage_collector
4331

44-
# Environment-specific configuration.
45-
require_dependency "environments/#{RAILS_ENV}"
46-
ActiveRecord::Base.configurations = YAML::load(File.open("#{RAILS_ROOT}/config/database.yml"))
47-
ActiveRecord::Base.establish_connection
32+
# Make Active Record use UTC-base instead of local time
33+
# config.active_record.default_timezone = :utc
34+
35+
# Use Active Record's schema dumper instead of SQL when creating the test database
36+
# (enables use of different database adapters for development and test environments)
37+
# config.active_record.schema_format = :ruby
4838

49-
50-
# Configure defaults if the included environment did not.
51-
begin
52-
RAILS_DEFAULT_LOGGER = Logger.new("#{RAILS_ROOT}/log/#{RAILS_ENV}.log")
53-
rescue StandardError
54-
RAILS_DEFAULT_LOGGER = Logger.new(STDERR)
55-
RAILS_DEFAULT_LOGGER.level = Logger::WARN
56-
RAILS_DEFAULT_LOGGER.warn(
57-
"Rails Error: Unable to access log file. Please ensure that log/#{RAILS_ENV}.log exists and is chmod 0666. " +
58-
"The log level has been raised to WARN and the output directed to STDERR until the problem is fixed."
59-
)
39+
# See Rails::Configuration for more options
6040
end
6141

62-
[ActiveRecord, ActionController, ActionMailer].each { |mod| mod::Base.logger ||= RAILS_DEFAULT_LOGGER }
63-
[ActionController, ActionMailer].each { |mod| mod::Base.template_root ||= "#{RAILS_ROOT}/app/views/" }
64-
ActionController::Routing::Routes.reload
65-
66-
Controllers = Dependencies::LoadingModule.root(
67-
File.expand_path(File.join(RAILS_ROOT, 'app', 'controllers')),
68-
File.expand_path(File.join(RAILS_ROOT, 'components'))
69-
)
42+
# Add new inflection rules using the following format
43+
# (all these examples are active by default):
44+
# Inflector.inflections do |inflect|
45+
# inflect.plural /^(ox)$/i, '\1en'
46+
# inflect.singular /^(ox)en/i, '\1'
47+
# inflect.irregular 'person', 'people'
48+
# inflect.uncountable %w( fish sheep )
49+
# end
7050

71-
# Include your app's configuration here:
51+
# Include your application configuration below

depot/db/development_structure.sql

+17-6
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,23 @@ CREATE TABLE `line_items` (
33
`product_id` int(11) NOT NULL default '0',
44
`order_id` int(11) NOT NULL default '0',
55
`quantity` int(11) NOT NULL default '0',
6-
`unit_price` float(10,2) NOT NULL default '0.00',
6+
`unit_price` decimal(10,2) NOT NULL default '0.00',
77
PRIMARY KEY (`id`),
8+
KEY `fk_items_product` (`product_id`),
89
KEY `fk_items_order` (`order_id`),
9-
KEY `fk_items_product` (`product_id`)
10-
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
10+
CONSTRAINT `fk_items_product` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`),
11+
CONSTRAINT `fk_items_order` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`)
12+
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
1113

1214
CREATE TABLE `orders` (
1315
`id` int(11) NOT NULL auto_increment,
1416
`name` varchar(100) NOT NULL default '',
15-
`email` text NOT NULL,
17+
`email` varchar(255) NOT NULL default '',
1618
`address` text NOT NULL,
19+
`pay_type` varchar(10) NOT NULL default '',
20+
`shipped_at` datetime default NULL,
1721
PRIMARY KEY (`id`)
18-
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
22+
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
1923

2024
CREATE TABLE `products` (
2125
`id` int(11) NOT NULL auto_increment,
@@ -25,5 +29,12 @@ CREATE TABLE `products` (
2529
`price` decimal(10,2) NOT NULL default '0.00',
2630
`date_available` datetime NOT NULL default '0000-00-00 00:00:00',
2731
PRIMARY KEY (`id`)
28-
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
32+
) ENGINE=MyISAM AUTO_INCREMENT=13 DEFAULT CHARSET=latin1;
33+
34+
CREATE TABLE `users` (
35+
`id` int(11) NOT NULL auto_increment,
36+
`name` varchar(100) NOT NULL default '',
37+
`hashed_password` varchar(40) default NULL,
38+
PRIMARY KEY (`id`)
39+
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
2940

0 commit comments

Comments
 (0)