At 04:16 AM 6/6/2006, you wrote:
…
I checked out that section and it tells you to type:
mysql -u root depot_developement to test to see if you can connect and I
get an error:
Error 1045 Access denied for user root@localhost using password NO
i am db challenged. on linux, i do a:
bin/mysqld_safe --user=mysql &
bin/mysqladmin -u root password ‘new-password’
bin/mysqladmin -u root -h hostname password ‘new-password’
using ‘’’ (two single quotes) to get an empy root login. not sure how
i did it on windoze.
But phpMyAdmin works fine with the root login, so I’m a little confused
as to why that is happening ?
i have no clue. but i am an old guy with nanosecond short term
memory, so i wrote a script that runs under cygwin on my windoze box
(see below). everything seems to work in the iteration A’s except for
the style sheet.
thanks
initialize() {
rm -rf $name
initializedb
}
initializedb() {
mysqladmin -f -u root drop ${name}_development
mysqladmin -u root create ${name}_development
mysqladmin -f -u root drop ${name}_test
mysqladmin -u root create ${name}_test
mysqladmin -f -u root drop ${name}_production
mysqladmin -u root create ${name}_production
}
showtables() {
for i in $*
do
mysql -u root <<-!!eof
use ${name}_development;
show tables;
describe $i;
!!eof
done
}
iterationA1() {
echo rake db:migrate
rake.bat db:migrate
echo script/generate model Product
ruby script/generate model Product
echo “edit migration file”
#read x
cat > db/migrate/001_create_products.rb <<-!!eof
class CreateProducts < ActiveRecord::Migration
def self.up
create_table :products do |t|
t.column :title, :string
t.column :description, :text
t.column :image_url, :string
end
end
def self.down
drop_table :products
end
end
!!eof
echo rake db:migrate
rake.bat db:migrate
showtables products
echo ruby script/generate controller admin
ruby script/generate controller admin
echo edit controller
cat > app/controllers/admin_controller.rb <<-!!eof
class AdminController < ApplicationController
scaffold :product
end
!!eof
}
iterationA2() {
ruby script/generate migration add_price
cat > db/migrate/002_add_price.rb <<-!!eof
class AddPrice < ActiveRecord::Migration
def self.up
add_column :products, :price, :integer, :default =>
0
end
def self.down
remove_column :products, :price
end
end
!!eof
rake.bat db:migrate
showtables products
}
iterationA3() {
cat > app/models/product.rb <<-!!eof
class Product < ActiveRecord::Base
validates_presence_of :title, :description,
:image_url
validates_numericality_of :price, :only_integer =>
true
validates_uniqueness_of :title
validates_format_of :image_url,
:with => %r{.(gif|jpg|png)$}i,
:message => “must be a URL for a GIF, JPG, or PNG
image”
protected
def validate
errors.add(:price, “should be positive”) if
price.nil? || price <= 0
end
end
!!eof
}
iterationA4() {
ruby script/generate scaffold product admin
ruby script/generate migration add_test_data
cat > db/migrate/003_add_test_data.rb <<-!!eof
class AddTestData < ActiveRecord::Migration
def self.up
Product.create(:title => 'Pragmatic Project
Automation’,
:description =>
%{
Pragmatic Project Automation shows
you how to improve the
consistency and repeatability of your
project’s procedures using
automation to reduce risk and errors.
Simply put, we’re going to put this thing
called a computer to work
for you doing the mundane (but important)
project stuff. That means
you’ll have more time and energy to do the
really
exciting—and difficult—stuff, like
writing quality code.
},
:image_url => ‘/images/auto.jpg’,
:price => 2995)
Product.create(:title => 'Pragmatic Version
Control’,
:description =>
%{
This book is a recipe-based approach to
using Subversion that will
get you up and running quickly—and
correctly. All projects need
version control: it’s a foundational piece
of any project’s
infrastructure. Yet half of all project
teams in the U.S. don’t use
any version control at all. Many others
don’t use it well, and end
up experiencing time-consuming problems.
},
:image_url => ‘/images/svn.jpg’,
:price => 2850)
# . . .
Product.create(:title => 'Pragmatic Unit Testing
(C#)',
:description =>
%{
Pragmatic programmers use feedback to drive
their development and
personal processes. The most valuable
feedback you can get while
coding comes from unit testing.
Without good tests in place, coding can
become a frustrating game of
“whack-a-mole.” That’s the carnival game
where the player strikes at a
mechanical mole; it retreats and another
mole pops up on the opposite side
of the field. The moles pop up and down so
fast that you end up flailing
your mallet helplessly as the moles continue
to pop up where you least
expect them.
},
:image_url => ‘/images/utc.jpg’,
:price => 2775)
end
def self.down
Product.delete_all
end
end
!!eof
rake.bat db:migrate
mysql -u root <<-!!eof
use ${name}_development;
show tables;
describe products;
select title,image_url from products;
!!eof
cat > app/views/layouts/admin.rhtml <<-!!eof
<html>
<head>
<title>Admin: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold', 'depot' %>
</head>
<body>
<p style="color: green"><%= flash[:notice] %></p>
<%= @content_for_layout %>
</body>
</html>
!!eof
cp ../images/* public/images/
cp ../depot.css public/stylesheets/
}
set -x
base=i:/work
PATH=/cygdrive/$base:$PATH
name=depot
cd $base
initialize
echo rails
rails.cmd $name
cd $name
echo iterationA1
iterationA1
Ruby script/server
echo iterationA2
iterationA2
iterationA3
iterationA4
ruby script/server
vice-chair http://ocjug.org/