Non riesco proprio a capire perche’ non funziona!!!
Procedo con ordine sperando che qualcuno mi aiuti.
- Seguendo questo link:
http://blog.mmediasys.com/2009/07/06/getting-started-with-rails-and-mysql/
ho installato il tutto ottenendo:
D:\work\prova>ruby -v
ruby 1.9.1p129 (2009-05-12 revision 23412) [i386-mingw32]
D:\work\prova>gem list
*** LOCAL GEMS ***
actionmailer (2.3.2)
actionpack (2.3.2)
activerecord (2.3.2)
activeresource (2.3.2)
activesupport (2.3.2)
mysql (2.8.1.1)
rails (2.3.2)
rake (0.8.7)
sqlite3-ruby (1.2.4.1)
su Windows XP.
- Ho creato da mysql i database prova_development, prova_test,
prova_production:
D:\work>mysql -uroot -p
Enter password: ************
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.0.85-community-nt MySQL Community Edition (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the current input
statement.
mysql> create database prova_development;
Query OK, 1 row affected (0.00 sec)
mysql> create database prova_test;
Query OK, 1 row affected (0.03 sec)
mysql> create database prova_production;
Query OK, 1 row affected (0.00 sec)
mysql> exit
Bye
- ho creato il file prova.rb in questo modo:
#!/usr/bin/ruby -w
simple.rb - simple MySQL script using Ruby MySQL module
require “mysql”
begin
# connect to the MySQL server
dbh = Mysql.real_connect(“localhost”, “root”, “rootsd100357”,
“prova_development”)
# get server version string and display it
puts "Server version: " + dbh.get_server_info
rescue Mysql::Error => e
puts “Error code: #{e.errno}”
puts “Error message: #{e.error}”
puts “Error SQLSTATE: #{e.sqlstate}” if e.respond_to?(“sqlstate”)
ensure
# disconnect from server
dbh.close if dbh
end
- lanciando il comando:
D:\work>ruby simple.rb
Server version: 5.0.85-community-nt
mi sembra tutto ok!!!
- creo il database su rails:
D:\work>rails prova --database=mysql
create
create app/controllers
create app/helpers
create app/models
create app/views/layouts
create config/environments
create config/initializers
create config/locales
create db
create doc
create lib
create lib/tasks
create log
create public/images
create public/javascripts
create public/stylesheets
create script/performance
create test/fixtures
create test/functional
create test/integration
create test/performance
create test/unit
create vendor
create vendor/plugins
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create Rakefile
create README
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create config/database.yml
create config/routes.rb
create config/locales/en.yml
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/new_rails_defaults.rb
create config/initializers/session_store.rb
create config/environment.rb
create config/boot.rb
create config/environments/production.rb
create config/environments/development.rb
create config/environments/test.rb
create script/about
create script/console
create script/dbconsole
create script/destroy
create script/generate
create script/runner
create script/server
create script/plugin
create script/performance/benchmarker
create script/performance/profiler
create test/test_helper.rb
create test/performance/browsing_test.rb
create public/404.html
create public/422.html
create public/500.html
create public/index.html
create public/favicon.ico
create public/robots.txt
create public/images/rails.png
create public/javascripts/prototype.js
create public/javascripts/effects.js
create public/javascripts/dragdrop.js
create public/javascripts/controls.js
create public/javascripts/application.js
create doc/README_FOR_APP
create log/server.log
create log/production.log
create log/development.log
create log/test.log
D:\work>
- controllo il file /config/database.yml:
MySQL. Versions 4.1 and 5.0 are recommended.
Install the MySQL driver:
gem install mysql
On Mac OS X:
sudo gem install mysql – --with-mysql-dir=/usr/local/mysql
On Mac OS X Leopard:
sudo env ARCHFLAGS=“-arch i386” gem install mysql –
–with-mysql-config=/usr/local/mysql/bin/mysql_config
This sets the ARCHFLAGS environment variable to your native
architecture
On Windows:
gem install mysql
Choose the win32 build.
Install MySQL and put its /bin directory on your path.
And be sure to use new-style password hashing:
development:
adapter: mysql
encoding: utf8
reconnect: false
database: prova_development
pool: 5
username: root
password:
host: localhost
Warning: The database defined as “test” will be erased and
re-generated from your development database when you run “rake”.
Do not set this db to the same as development or production.
test:
adapter: mysql
encoding: utf8
reconnect: false
database: prova_test
pool: 5
username: root
password:
host: localhost
production:
adapter: mysql
encoding: utf8
reconnect: false
database: prova_production
pool: 5
username: root
password:
host: localhost
- creo il database con rake:
D:\work\prova>rake db:create
(in D:/work/prova)
Couldn’t create database for {“adapter”=>“mysql”, “encoding”=>“utf8”,
"reconnect
"=>false, “database”=>“prova_development”, “pool”=>5,
“username”=>“root”, “passw
ord”=>nil, “host”=>“localhost”}, charset: utf8, collation:
utf8_general_ci (if y
ou set the charset manually, make sure you have a matching collation)
giustamente non mi fa eseguire il comando. !!!
- modifico il file database.yml
MySQL. Versions 4.1 and 5.0 are recommended.
Install the MySQL driver:
gem install mysql
On Mac OS X:
sudo gem install mysql – --with-mysql-dir=/usr/local/mysql
On Mac OS X Leopard:
sudo env ARCHFLAGS=“-arch i386” gem install mysql –
–with-mysql-config=/usr/local/mysql/bin/mysql_config
This sets the ARCHFLAGS environment variable to your native
architecture
On Windows:
gem install mysql
Choose the win32 build.
Install MySQL and put its /bin directory on your path.
And be sure to use new-style password hashing:
development:
adapter: mysql
encoding: utf8
reconnect: false
database: prova_development
pool: 5
username: root
password: rootsd100357
host: localhost
Warning: The database defined as “test” will be erased and
re-generated from your development database when you run “rake”.
Do not set this db to the same as development or production.
test:
adapter: mysql
encoding: utf8
reconnect: false
database: prova_test
pool: 5
username: root
password: rootsd100357
host: localhost
production:
adapter: mysql
encoding: utf8
reconnect: false
database: prova_production
pool: 5
username: root
password: rootsd100357
host: localhost
- riprovo con rake:
D:\work\prova>rake db:create
(in D:/work/prova)
rake aborted!
syntax error on line 24, col 2: ` host: localhost’
(See full trace by running task with --trace)
!!!
D:\work\prova>rake db:create --trace
(in D:/work/prova)
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Invoke rails_env (first_time)
** Execute rails_env
** Execute db:load_config
rake aborted!
syntax error on line 24, col 2: host: localhost' c:/ruby19/lib/ruby/1.9.1/yaml.rb:133:in
load’
c:/ruby19/lib/ruby/1.9.1/yaml.rb:133:in load' c:/ruby19/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/initializer.rb:880:in
databa
se_configuration’
c:/ruby19/lib/ruby/gems/1.9.1/gems/rails-2.3.2/lib/tasks/databases.rake:4:in
bl ock (2 levels) in <top (required)>' c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in
call’
c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:636:in block in execu te' c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in
each’
c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:631:in
execute' c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:597:in
block
in invok
e_with_call_chain’
c:/ruby19/lib/ruby/1.9.1/monitor.rb:190:in mon_synchronize' c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:590:in
invoke_with_ca
ll_chain’
c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:607:in block in invok e_prerequisites' c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:604:in
each’
c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:604:in
invoke_prerequ isites' c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:596:in
block
in invok
e_with_call_chain’
c:/ruby19/lib/ruby/1.9.1/monitor.rb:190:in mon_synchronize' c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:590:in
invoke_with_ca
ll_chain’
c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:583:in
invoke' c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2051:in
invoke_task’
c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in block (2 leve ls) in top_level' c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in
each’
c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2029:in block in top_ level' c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_exce
ption_handling’
c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2023:in
top_level' c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2001:in
block
in run’
c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_exce ption_handling' c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib/rake.rb:1998:in
run’
c:/ruby19/lib/ruby/gems/1.9.1/gems/rake-0.8.7/bin/rake:31:in <top (required)>' c:/Ruby19/bin/rake:19:in
load’
c:/Ruby19/bin/rake:19:in `’
D:\work\prova>
!!!
Potete cercare di aiutarmi !!!
Grazie, Sergio.