Depot for MySQL5.0, Rails2.0 in WindowXP,
# means comments, Hope you can enjoy it.
[b][color=red]
Objective: To build the basic skeleton of depot[/color][/b]
1. create depot rails project
[b][color=blue]rails depot[/color][/b]
2. edit config/database.yml
[b][color=blue]development:
adapter: mysql
database: depot_development
username: root
password: admin
host: 127.0.0.1
test:
adapter: mysql
database: depot_test
username: root
password: admin
host: 127.0.0.1
production:
adapter: mysql
database: depot_production
username: root
password: admin
host: 127.0.0.1[/color][/b]
3. create database defined in database.yml
[b][color=blue]rake db:drop:all #drop database defined in database.yml
rake db:create:all #create database defined in database.yml
rake db:version #print database version[/color][/b]
#rake db:rollback #rollback database to last version, do not need to type this in this sample
4. create product RESTful
[b][color=blue]ruby script/generate scaffold product title:string description:text image_url:string[/color][/b]
#Remember now that Rails 2.0 is RESTful by default. The only difference here is that the ‘scaffold’ behaves like the ‘scaffold_resource’ we had before, and the old non-RESTful scaffold is gone. You also don’t have the ActionController class method ‘scaffold’ that dynamically populated your empty controller with default actions. So, everything scaffold we do is RESTful now. It will create the usual suspects: Controller, Helper, Model, Migration, Unit Test, Functional Test.
#Please check app/controllers/products_controller.rb for confirm
5. Migrate product into database.
[b][color=blue]rake db:migrate[/color][/b]
#Please check the coressponding database with the table named "products" for confirm
6. start Webrick server.
[b][color=blue]ruby script/server[/color][/b]
7. test depot in web browser.
[b][color=blue]http://localhost:3000/products[/color][/b]
# means comments, Hope you can enjoy it.
[b][color=red]
Objective: To build the basic skeleton of depot[/color][/b]
1. create depot rails project
[b][color=blue]rails depot[/color][/b]
2. edit config/database.yml
[b][color=blue]development:
adapter: mysql
database: depot_development
username: root
password: admin
host: 127.0.0.1
test:
adapter: mysql
database: depot_test
username: root
password: admin
host: 127.0.0.1
production:
adapter: mysql
database: depot_production
username: root
password: admin
host: 127.0.0.1[/color][/b]
3. create database defined in database.yml
[b][color=blue]rake db:drop:all #drop database defined in database.yml
rake db:create:all #create database defined in database.yml
rake db:version #print database version[/color][/b]
#rake db:rollback #rollback database to last version, do not need to type this in this sample
4. create product RESTful
[b][color=blue]ruby script/generate scaffold product title:string description:text image_url:string[/color][/b]
#Remember now that Rails 2.0 is RESTful by default. The only difference here is that the ‘scaffold’ behaves like the ‘scaffold_resource’ we had before, and the old non-RESTful scaffold is gone. You also don’t have the ActionController class method ‘scaffold’ that dynamically populated your empty controller with default actions. So, everything scaffold we do is RESTful now. It will create the usual suspects: Controller, Helper, Model, Migration, Unit Test, Functional Test.
#Please check app/controllers/products_controller.rb for confirm
5. Migrate product into database.
[b][color=blue]rake db:migrate[/color][/b]
#Please check the coressponding database with the table named "products" for confirm
6. start Webrick server.
[b][color=blue]ruby script/server[/color][/b]
7. test depot in web browser.
[b][color=blue]http://localhost:3000/products[/color][/b]