Ruby on rails開發從頭來(windows)(四)-第一個添刪查改例子

來源:互聯網
上載者:User

在上一篇Ruby on rails開發從頭來(windows)(三)-實現頁面間的跳轉中,我們建立了兩個頁面來進行跳轉遷移,這次我們來寫一個單表維護的添刪查改的例子。

1.這次我們重新建立一個項目depot,按照上篇中的步驟,建立depot項目。

2.建立資料庫。

你可以使用rails的命令列,通過mysql建立,先定位到depot目錄,使用命令:

depot> mysql -u root –p

密碼為空白,串連mysql後執行下面的命令:

mysql> create database depot_development;  mysql> create database depot_test;  mysql> create database depot_production;  mysql> grant all on depot_development.* to 'dave'@'localhost';  mysql> grant all on depot_test.* to 'dave'@'localhost';  mysql> grant all on depot_production.* to 'prod'@'localhost' identified by 'wibble';  mysql> exit

建立資料庫完成後,修改depotconfig目錄下的database.yml檔案的內容,將其中development庫和test庫的username項設定為空白。

你也可以用InstantRails中內建的phpmyadmin來建立,PhpMyAdmin的啟動可以按照下圖:

在這裡我們要建立三個資料庫depot_development,depot_test,depot_public,這三個庫分別用於開發,測試,發布。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.