浏览 2615 次
该帖已经被评为新手帖
|
|
---|---|
作者 | 正文 |
发表时间:2008-06-24
# means comments, Hope you can enjoy it. Objective: To build the basic skeleton of depot 1. create depot rails project rails depot 2. edit config/database.yml 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 3. create database defined in database.yml 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 #rake db:rollback #rollback database to last version, do not need to type this in this sample 4. create product RESTful ruby script/generate scaffold product title:string description:text image_url:string #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. rake db:migrate #Please check the coressponding database with the table named "products" for confirm 6. start Webrick server. ruby script/server 7. test depot in web browser. http://localhost:3000/products 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-06-25
http://zhangpeihao.iteye.com/admin/blogs/200033
我将depot改成Rails2.0的代码。 |
|
返回顶楼 | |
发表时间:2008-08-21
第一步
Rails depot 可以直接改为 Rails -d mysql depot 则database.yml直接生成mysql模板的连接信息,只需要修改密码就可以 |
|
返回顶楼 | |