Mac要先安裝Mysql (透過brew),指令如下:
brew install mysql
|
再來是到Rails中安裝mysql的gem,進到目錄下編輯Gemfile,加入這行
gem 'mysql2'
|
然後
bundle install
|
可以先到MAMP的phpMyAdmin建立好一個資料庫和User來使用
(MAMP預設的phpMyAdmin位置是 http://localhost:8888/phpMyAdmin/ )
參考以下步驟
然後建立使用者
接下來是回到Rails
建立個測試用的Model (終端機指令輸入如下)
rails g model member account:string password:string name:string email:string
|
可以看見Rails的異動如下:
invoke active_record
create db/migrate/20150831180104_create_members.rb
create app/models/member.rb
invoke test_unit
create test/models/member_test.rb
create test/fixtures/members.yml
|
最後是設定 config/database.yml ,將原來的 sqlite改成mysql
註:MAMP或是某些特別的的MySQL需要另外設定Socket (重要)
MAMP的MySQL Socket預設是在 /Applications/MAMP/tmp/mysql/mysql.sock
database.yml範例:
… (略)
default: &default
adapter: mysql2
encoding: utf8
database: test_001
host: localhost
username: test_001
password: **************
socket: /Applications/MAMP/tmp/mysql/mysql.sock
development:
<<: *default
# database: db/development.sqlite3
… (略)
|
請注意yml的縮排很嚴格,上面的縮排是用二個空白
然後所有的 sqlite有關的全部注解掉 ( yml中的#是註解) ,例如
test:
<<: *default
# database: db/test.sqlite3
production:
<<: *default
# database: db/production.sqlite3
|
然後在Rails中試看看建立db,輸入
rake db:migrate
|
如果沒有錯誤,再到phpMyAdmin就會看到Ruby on Rails幫我們建立的Table 了 :)
What you need to know about the casinos to bet on - Dr. McD
回覆刪除Casino bonuses do 고양 출장마사지 not include 충주 출장샵 anything less than the 강릉 출장샵 casino bonus. The following is a list of 통영 출장샵 all 영주 출장안마 casino bonuses and promotions offered by the