Ruby on Railsの開発環境をつくってみよう! / GMO HosCon #19 Tokyo

69b93af68320a590f607c296e8edff73?s=47 Ken’ichiro Oyama
July 17, 2018
570

Ruby on Railsの開発環境をつくってみよう! / GMO HosCon #19 Tokyo

69b93af68320a590f607c296e8edff73?s=128

Ken’ichiro Oyama

July 17, 2018
Tweet

Transcript

  1. ॳ৺ऀ޲͚3BJMTೖ໳ϋϯζΦϯ ϚωʔδυΫϥ΢υνʔϜ(.01FQBCP *OD ୈճ(.0ϗείϯ 3VCZPO3BJMTͷ ։ൃ؀ڥΛͭͬͯ͘ΈΑ͏ʂ  

  2. ϋογϡλά IPTDPONDMPMJQPQ  

  3. ࠓճͷϋϯζΦϯͷ໨ඪ  

  4. 3VCZPO3BJMTͷ ؆୯ͳΞϓϦέʔγϣϯΛ Πϯλʔωοτʹެ։͢Δ  

  5. ͭͷΩʔϫʔυ ϩϦϙοϓʂϚωʔδυΫϥ΢υ λʔϛφϧ ύοέʔδϚωʔδϟ)PNFCSFX ΤσΟλ"UPN ϓϩάϥϛϯάݴޠ3VCZ όʔδϣϯ؅ཧπʔϧ(JU 8FCϑϨʔϜϫʔΫ3VCZPO3BJMT  

  6. 3VCZPO3BJMTΞϓϦΛ։ൃͯ͠Πϯλʔωοτʹެ։͢ΔΠϝʔδ   SQLite3

  7. ͭͷ΍Δ͜ͱ ϩϦϙοϓʂϚωʔδυΫϥ΢υͰΞΧ΢ϯτΛ࡞੒͠Α͏ λʔϛφϧΛىಈͯ͠৮ͬͯΈΑ͏ ύοέʔδϚωʔδϟ)PNFCSFXΛΠϯετʔϧͯ͠ΈΑ͏ )PNFCSFXΛ࢖ͬͯΤσΟλ"UPNɺϓϩάϥϛϯάݴޠ3VCZɺόʔδϣϯ؅ཧπʔϧ(JUΛ Πϯετʔϧͯ͠ΈΑ͏ 3VCZPO3BJMTΞϓϦΛखݩͰىಈͯ͠ΈΑ͏ 3VCZPO3BJMTΞϓϦΛϚωʔδυΫϥ΢υʹɺϚωʔδυΫϥ΢υͷ࢓૊ΈΛ࢖ͬͯΞοϓϩʔ υ σϓϩΠ

    ͯ͠ΈΑ͏ 3VCZPO3BJMTΞϓϦΛमਖ਼ͯ͠ɺϚωʔδυΫϥ΢υʹ൓өͯ͠ΈΑ͏  
  8. ϩϦϙοϓʂϚωʔδυΫϥ΢ υͰΞΧ΢ϯτΛ࡞੒͠Α͏  

  9. ϩϦϙοϓʂϚωʔδυΫϥ΢υͰΞΧ΢ϯτΛ࡞੒͠Α͏ wࠓճ͸։ൃ؀ڥʹϩϦϙοϓʂϚωʔδυΫϥ΢υΛ׆༻͠·͢ wʮϚωʔδυΫϥ΢υʯͰݕࡧɻNDMPMJQPQKQͷϦϯΫΛΫϦοΫ wʮࠓ͙͢͸͡ΊΔʯΛΫϦοΫ ɹɹɹϚωʔδυΫϥ΢υ ݕࡧΩʔϫʔυͰ͢ɻ༗ޮ׆༻͍ͯͩ͘͠͞  

  10. ϝʔϧΞυϨεͱύεϫʔυΛೖྗ  

  11. ϝʔϧΞυϨεͱύεϫʔυΛೖྗ wಧ͍ͨϝʔϧΛΫϦοΫͯ͠ೝূ͠·͠ΐ͏  

  12. ϓϩδΣΫτΛ௥Ճͯ͠ΈΑ͏ wʮϓϩδΣΫτ࡞੒ʹਐΉʯΛΫϦοΫ  

  13. ϓϩδΣΫτΛ௥Ճͯ͠ΈΑ͏ w ΞϓϦέʔγϣϯબ୒Ͱ3VCZPO3BJMTΛΫϦοΫ w ΧελϜυϝΠϯͱσʔλϕʔεͷύεϫʔυΛೖྗ w σʔλϕʔεͷύεϫʔυ͸ϝϞ͓͍͍ͯͯͩ͘͠͞  

  14. ϓϩδΣΫτΛ௥Ճͯ͠ΈΑ͏ wʮ࡞੒͢ΔʯΛΫϦοΫ  

  15. ϓϩδΣΫτΛ௥Ճͯ͠ΈΑ͏ wίϯςφͷ४උΛ଴ͪ·͢ɻɻɻ  

  16. ϓϩδΣΫτΛ௥Ճͯ͠ΈΑ͏ Ͱ͖ͨʂ  

  17. λʔϛφϧΛىಈͯ͠৮ͬͯΈΑ ͏  

  18. λʔϛφϧͬͯԿʁ w จࣈͰ.BD#PPL΍ͦͷଞ͍Ζ͍ΖϓϩάϥϜΛૢ࡞͢ΔͨΊͷϞϊɾπʔϧɾΞϓ Ϧέʔγϣϯ ◦ CUIʢΩϟϥΫλʔɾϢʔβɾΠϯλʔϑΣʔε : จࣈUIʣ ◦ ൓ରʹϚ΢εͰΫϦοΫͨ͠Γը໘Ͱͷૢ࡞͕͋Δͷ͸GUIʢάϥϑΟΧϧɾϢʔ

    βɾΠϯλʔϑΣʔε : άϥϑΟΧϧͳUIʣ • ίϚϯυ΍εΫϦϓτʢϓϩάϥϜ͕ղऍͰ͖ΔจࣈྻʣΛೖྗ͢Δ͜ͱͰ༷ʑͳૢ ࡞͕Ͱ͖Δ • ͳΜͰλʔϛφϧʁ ◦ ίϚϯυ͕จࣈͳͷͰϋοΩϦ͍ͯ͠Δͷ͕޷·Ε͍ͯΔ ◦ ʮ**ͱ͍͏ίϚϯυΛ࣮ߦͯ͠Έͯʯ ɹɹɹλʔϛφϧɺ#BTI  
  19. λʔϛφϧΛىಈͯ͠ΈΑ͏ w.BDͷӈ্ͷ஬؟ڸʢݕࡧʣϘλϯΛΫϦοΫ 4QPUMJHIU ɹɹɹ4QPUMJHIU  

  20. λʔϛφϧΛىಈͯ͠ΈΑ͏ wʮλʔϛφϧʯͱݕࡧͯ͠&OUFSىಈ  

  21. λʔϛφϧΛىಈͯ͠ΈΑ͏  

  22. λʔϛφϧͰૢ࡞ͯ͠ΈΑ͏ wQXE wDE wMT wPQFO ࠷ޙʹυοτ͕͋ΔͷͰ஫ҙ  w'JOEFSͱ࿈ܞ ɹɹɹ.BDίϚϯυzɺz-JOVYίϚϯυ 

    
  23. 5JQTίϚϯυΛ࣮ߦͨ͠ΒԿ͔ग़ͨ w߄ͯͣʹಡΜͰΈ·͠ΐ͏ w؆୯ͳӳޠͰ͋Δ͜ͱ͕ଟ͍Ͱ͢ wʮ͏·͍͍ͬͯ͘ΔΑʯͱ͍͏ϝοηʔδ͔΋͠Ε·ͤΜ͠ wʮΤϥʔͩΑʯͱ͍͏ϝοηʔδ͔΋͠Ε·ͤΜ w΋͠ɺΤϥʔͷͱ͖͸࣍ʹਐ·ͣελοϑΛݺΜͰ͍ͩ͘͞  

  24. 5JQTίϐʔϖʔετͱλʔϛφϧͰͷ࣮ߦ wλʔϛφϧͰ͸ίϚϯυΛೖྗ͝&OUFSʢվߦʣΛͨ͠Β࣮ߦ w΋͠ɺվߦ͞Ε͍ͯΔεΫϦϓτΛλʔϛφϧʹίϐʔͯ͠షΓ෇͚ ͨΒ࣮ߦ͞ΕΔͷͰ஫ҙ͠·͠ΐ͏  

  25. 5JQT'JOEFS͔ΒλʔϛφϧΛ։͚ΔΑ͏ʹ͠Α͏ w PQFOίϚϯυͰλʔϛφϧ͔Β'JOEFSΛ։͚ ͨͷͰɺʮٯʯΛͰ͖ΔΑ͏ʹ͠·͠ΐ͏ w <γεςϜ؀ڥઃఆ><ΩʔϘʔυ><γϣʔ τΧοτ>λϒͰ<αʔϏε>ʹ͋Δ<ϑΥϧμʹ৽ نλʔϛφϧ>ʹνΣοΫΛ͍ΕΔ  

  26. ύοέʔδϚωʔδϟ )PNFCSFXΛ Πϯετʔϧͯ͠ΈΑ͏  

  27. ύοέʔδϚωʔδϟ)PNFCSFXͬͯԿʁ wΤϯδχΞ͕࢖͏"QQ4UPSFΈ͍ͨͳ΋ͷʢ.BD༻ʣ wओʹλʔϛφϧͰ࣮ߦ͠·͢ wλʔϛφϧͰ࢖͏ίϚϯυ͔ΒΤσΟλͷΑ͏ͳΞϓϦέʔγϣϯ· Ͱ؆୯ʹΠϯετʔϧΞϯΠϯετʔϧͰ͖·͢ ɹɹɹl.BD)PNFCSFX  

  28. )PNFCSFXΛΠϯετʔϧͯ͠ΈΑ͏ wλʔϛφϧͰ YDPEFTFMFDUJOTUBMM Λ࣮ߦ w࣮ߦͰ͖ͳ͍৔߹͸"QQ4UPSFͰ9$PEFΛΠϯετʔϧ wʮ)PNFCSFXʯͰݕࡧ wIUUQTCSFXTIJOEFY@KBͷΠϯετʔϧεΫϦϓτΛίϐʔͯ͠λʔ ϛφϧʹϖʔετ࣮ͯ͠ߦ  

  29. )PNFCSFXΛ࢖ͬͯ ΤσΟλ"UPNɺ ϓϩάϥϛϯάݴޠ3VCZɺ όʔδϣϯ؅ཧπʔϧ(JUΛ Πϯετʔϧͯ͠ΈΑ͏  

  30. ΤσΟλ"UPNͷΠϯετʔϧ > brew cask install atom ɹɹɹΤσΟλ"UPN  

  31. ࿅शΤσΟλ"UPN wλʔϛφϧͰͲ͔͜ͷσΟϨΫτϦʹҠಈͯ͠ɺͦ͜ʹ"UPNͰϑΝ ΠϧΛ࡞੒ͯ͠Έ·͠ΐ͏ •࢖͏ίϚϯυ: •cd •open . •atom ϑΝΠϧ໊ 

    
  32. ϓϩάϥϛϯάݴޠ3VCZͷΠϯετʔϧ > brew install readline ruby-build rbenv > brew install

    mysql # MySQLͷΠϯετʔϧ > echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile > echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile > source ~/.bash_profile > rbenv install 2.5.1 > rbenv global 2.5.1 > ruby -v   ɹɹɹl.BD3VCZSCFOWz
  33. όʔδϣϯ؅ཧπʔϧ(JUͷΠϯετʔϧ > brew install git > git config --global user.name

    "[໊લΛೖΕ͍ͯͩ͘͞]" > git config --global user.email "[ϝʔϧΞυϨεΛೖΕ͍ͯͩ͘͞]" > git --version ɹɹɹ(JU  
  34. 3VCZPO3BJMTΞϓϦΛ खݩͰىಈͯ͠ΈΑ͏  

  35. 3VCZPO3BJMTΛ࢖͏લͷલ४උ ඞཁͳ3VCZ੡ͷίϚϯυΛΠϯετʔϧ > gem install bundler --no-document > gem install

    rails --no-document ɹɹɹ3VCZ#VOEMFS3VCZHFN  
  36. 3VCZPO3BJMTΞϓϦΛ։ൃͯ͠Πϯλʔωοτʹެ։͢ΔΠϝʔδ   SQLite3

  37. 3VCZPO3BJMTϓϩδΣΫτΛ࡞੒͠Α͏ wͭͭͷϓϩδΣΫτ͕8FCΞϓϦέʔγϣϯ wେ͖͍αʔϏεͩͱͭҎ্ͷϓϩδΣΫτ͔Βߏ੒͞ΕΔ͜ͱ΋ wࠓճ͸IPTDPOͱ͍͏໊લͷϓϩδΣΫτΛͭ࡞੒͠·͢ > cd [Ͳ͔͜Կ͔࡞ͬͯྑ͍σΟϨΫτϦ] > rails new

    hoscon  
  38. σʔλϕʔεͷ઀ଓઃఆΛ͠Α͏ > cd hoscon/ > atom config/database.yml  

  39. σʔλϕʔεͷ઀ଓઃఆΛ͠Α͏  

  40. σʔλϕʔεͷ઀ଓઃఆΛ͠Α͏ wෆඞཁͳλϒΛফ͢ͱ͜ͷ Α͏ʹͳΓ·͢  

  41. σʔλϕʔεͷ઀ଓઃఆΛ͠Α͏ default: &default adapter: sqlite3 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5

    } %> timeout: 5000 development: <<: *default database: db/development.sqlite3 test: <<: *default database: db/test.sqlite3 production: <<: *default adapter: mysql2 database: [ϚωΫϥͷϓϩδΣΫτը໘Λ֬ೝ] username: [ϚωΫϥͷϓϩδΣΫτը໘Λ֬ೝ] password: [ϝϞͨ͠σʔλϕʔεͷύεϫʔυ] host: [ϚωΫϥͷϓϩδΣΫτը໘Λ֬ೝ]  
  42. σʔλϕʔεͷ઀ଓઃఆΛ͠Α͏ wຊ൪ͷσʔλϕʔεઃఆ͸ϚωʔδυΫϥ΢υͷϓϩδΣΫτը໘Λ ֬ೝ  

  43. (FNpMFͷઃఆʹANZTRMAΛ௥Ճ͠Α͏ wࠓճ͸ϚωʔδυΫϥ΢υͰ.Z42-ʹ઀ଓ͢ΔͷͰNZTRMͱ͍͏ HFNΛ௥Ճ͠·͢ʢຊ൪؀ڥ͚ͩʣ > cd hoscon/ > atom Gemfile #

    ຤ඌʹҎԼΛ௥Ճ # gem 'mysql2' > bundle install ɹɹɹ(FNpMFl3BJMTNZTRM  
  44. 3VCZPO3BJMTΛىಈͯ͠ΈΑ͏ wϒϥ΢βͰIUUQMPDBMIPTU ʹΞΫηεͰ͖·͢ > cd hoscon/ > rails server #

    Ctrl+C ͰऴྃͰ͖·͢ ɹɹɹlSBJMTTFSWFSz  
  45. ϓϩδΣΫτͷιʔείʔυΛίϛοτ͠Α͏ wόʔδϣϯ؅ཧπʔϧ(JUΛར༻ͯ͠ࠓ·ͰͷιʔείʔυΛه࿥ʢί ϛοτʣ͠·͢ > git init # σΟϨΫτϦΛGitͰ؅ཧ͢ΔΑ͏ʹઃఆ > git

    add . # શͯͷ௥Ճͯ͠Α͍ϑΝΠϧΛGitʹ؅ཧͤ͞Δ > git commit -m 'My First Commit’ # ίϛοτ > git log # ίϛοτͷϩάΛ֬ೝ ɹɹɹlHJUJOJUlHJUMPHz  
  46. ιʔείʔυΛमਖ਼ͯ͠ίϛοτ͠Α͏ wϒϥ΢βͰIUUQMPDBMIPTUJEFBT ʹΞΫηεͯ͠ΈΑ͏ > rails generate scaffold idea name:string description:text

    picture:string # ideas ςʔϒϧΛ࡞ͬͯૢ࡞͢ΔͨΊͷίʔυΛੜ੒ > rails db:migrate # ideas ςʔϒϧΛ࡞੒ > rails server # αʔόΛىಈ ɹɹɹlSBJMTίϚϯυzl$36%zlTDB⒎PMEz  
  47. ιʔείʔυΛमਖ਼ͯ͠ίϛοτ͠Α͏ wSBJMTHFOFSBUFͰࣗಈͰߦΘΕͨमਖ਼Λ(JUΛར༻ͯ֬͠ೝɾه࿥ ʢίϛοτʣ͠Α͏ > git status # ιʔείʔυͷมߋঢ়ଶΛ֬ೝͰ͖·͢ > git

    diff # ιʔείʔυͷࠩ෼Λ֬ೝͰ͖·͢ > git add . > git commit -m 'My Second Commit' > git log ɹɹɹl(JUίϚϯυz  
  48. 3VCZPO3BJMTΞϓϦΛ ϚωʔδυΫϥ΢υʹɺ ϚωʔδυΫϥ΢υͷ࢓૊ΈΛ࢖ͬ ͯΞοϓϩʔυ σϓϩΠ ͯ͠ΈΑ ͏  

  49. σϓϩΠલͷલ४උ 44)ͷެ։伴ͷઃఆ wϚωʔδυΫϥ΢υʹ44)Ͱ઀ଓͰ͖ΔΑ͏ʹઃఆ͠·͠ΐ͏ wϚωʔδυΫϥ΢υ44)ίϚϯυͷ෦෼Λίϐʔͯ͠λʔϛφϧͰ࣮ ߦͯ͠Έ·͠ΐ͏  

  50. σϓϩΠલͷલ४උ 44)ͷެ։伴ͷઃఆ wެ։伴ͱൿີ伴ͷରΛ࡞੒ͯ͠ɺެ։伴ΛΫϦοϓϘʔυʹίϐʔ͠ ·͢ > install -m 0700 -d ~/.ssh

    # σΟϨΫτϦͷ࡞੒ > ssh-keygen -t rsa -b 4096 -f ~/.ssh/id_rsa # ެ։伴ͱൿີ伴Λ࡞੒ > cat ~/.ssh/id_rsa.pub | pbcopy # ެ։伴ΛΫϦοϓϘʔυʹίϐʔ ɹɹɹlDBUίϚϯυlQCDPQZz  
  51. σϓϩΠલͷલ४උ ϚωʔδυΫϥ΢υʹެ։伴Λొ࿥ wϚωʔδυΫϥ΢υӈ্ͷϝχϡʔ͔Β44)ެ։伴ͷొ࿥ΛΫϦοΫ  

  52. σϓϩΠલͷલ४උ ϚωʔδυΫϥ΢υʹެ։伴Λొ࿥ w44)ެ։伴Λϖʔετͯ͠ొ࿥͠·͢  

  53. σϓϩΠલͷલ४උ ϚωʔδυΫϥ΢υʹެ։伴Λొ࿥ w΋͏Ұճ44)ίϚϯυΛ࣮ߦͯ͠Έ·͠ΐ͏  

  54. σϓϩΠલͷલ४උ TFDSFU@LFZ@CBTFͷઃఆ wϚωʔδυΫϥ΢υ͸ຊ൪؀ڥ QSPEVDUJPO ͱͯ͠ಈ͖·͢ w3BJMTͰ͸TFDSFU@LFZ@CBTFͷઃఆ͕ඞཁͰ͢ > EDITOR=‘atom —-wait’ bin/rails

    credentials:edit ɹɹɹlSBJMTTFDSFU@LFZ@CBTFz  
  55. σϓϩΠલͷલ४උ NBTUFSLFZͷίϛοτ wϚωʔδυΫϥ΢υ͸ຊ൪؀ڥ QSPEVDUJPO ͱͯ͠ಈ͖·͢ wຊདྷͰ͋Ε͹NBTUFSLFZ͸ຊ൪؀ڥʹ(JUͱ͸ผͰઃஔ͢Δͷ͕๬· ͍͠Ͱ͕͢ɺࠓճ͸؆୯ͷͨΊʹNBTUFSLFZ΋ίϛοτ͠·͢ > git add

    -f config/master.key > git commit -m 'Add master.key THIS IS BAD WAY' ɹɹɹlSBJMTTFDSFU@LFZ@CBTFz  
  56. σϓϩΠલͷલ४උ ੩తϑΝΠϧ΋3BJMTͰ഑৴͢Δ wࠓճ͸ϚωʔδυΫϥ΢υίϯςφͰಈ͘ͷͰ੩తϑΝΠϧ΋3BJMT Ͱ഑৴͢ΔΑ͏ʹઃఆ͠·͠ΐ͏ wҰൠతʹ͸੩తϑΝΠϧ͸3BJMTͰ͸ͳ͘8FCαʔόʹ഑৴Λ೚ͤ ΔͳͲͷઃఆΛ͢Δͱྑ͍Ͱ͢ w > atom config/environments/production.rb

    ɹɹɹlSBJMT੩తϑΝΠϧz  
  57. σϓϩΠલͷલ४උ ੩తϑΝΠϧ΋3BJMTͰ഑৴͢Δ w๨Εͣʹίϛοτ > git add . > git commit

    -m ‘Rails public server enabled’  
  58. ϚωʔδυΫϥ΢υ༻ͷσϓϩΠ༻(JUͱ࿈ܞ͢Δ wϚωʔδυΫϥ΢υͷ3BJMTίϯςφͱ/PEFίϯςφ͸σϓϩΠ༻(JU ϦϙδτϦ͕͋Γ·͢ wͦͷσϓϩΠ༻ϦϙδτϦʹιʔείʔυΛHJUQVTI͢Δ͜ͱͰɺ ϚωʔδυΫϥ΢υʹσϓϩΠ͕Ͱ͖·͢ ɹɹɹlHJUQVTIz  

  59. ϚωʔδυΫϥ΢υ༻ͷσϓϩΠ༻(JUͱ࿈ܞ͢Δ wϚωʔδυΫϥ΢υͷϓϩδΣΫτը໘͔ΒʮϦϙδτϦʯΛίϐʔ ͯ͠ɺλʔϛφϧͰ࣮ߦ ɹɹɹlHJUSFNPUFBEEz  

  60. ϚωʔδυΫϥ΢υ༻ͷσϓϩΠ༻(JUͱ࿈ܞ͢Δ wIUUQT MPMJQPQJPJEFBTʹΞΫηεͯ͠Έ·͠ΐ͏ ɹɹɹlHJUQVTIz > git push lolipop master 

    
  61. ͜͜·ͰͰ ϋϯζΦϯͷϝΠϯηογϣϯ͸ ऴྃͰ͢  

  62. 3VCZPO3BJMTΞϓϦΛमਖ਼͠ ͯɺϚωʔδυΫϥ΢υʹ൓өͯ͠ ΈΑ͏  

  63. ϚωʔδυΫϥ΢υΛ࢖ͬͯ։ൃΛ͠Α͏ w࣮͸͜͜·ͰͰɺʮ3BJMT(JSMTʯͱ͍͏ϓϩδΣΫτͷʮ3BJMT(JSMTΨ Πυʯͷʮ͸͡ΊͯΞϓϦνϡʔτϦΞϧʯͷʮ*EFBͷTDB⒎PME Λ͢Δʯ·ͰऴΘ͍ͬͯ·͢ wʮ͋ͳͨͷΞϓϦΛΠϯλʔωοτʹެ։͠Α͏ʯ΋͢ͰʹͰ͖ͯ ͍·͢Ͷ w࣍͸ʮσβΠϯ͢ΔʯͰ͢ɻੋඇਐΊ͍ͯͬͯΈ·͠ΐ͏ ɹɹɹl3BJMT(JSMTz  

  64. ΞϯέʔτΛੋඇ͓ئ͍͠·͢ʂʂ  

  65. ϥΠηϯε w͜ͷϋϯζΦϯͷࢿྉͷҰ෦͸3BJMT(JSMTΨΠυ ೔ຊޠ൛  IUUQ SBJMTHJSMTKQ Λࢀߟʹ͍ͯ͠·͢ɻ·ͨɺ3BJMT(JSMTΨΠυʹͭͳ͕ ΔΑ͏ʹ࡞ΒΕ͍ͯ·͢ɻ 3BJMT(JSMTΨΠυϥΠηϯε 5IJTXPSLJTMJDFOTFEVOEFSB$SFBUJWF$PNNPOT"UUSJCVUJPO4IBSF"MJLF-JDFOTF

    IUUQDSFBUJWFDPNNPOTPSHMJDFOTFTCZTB 3BJMT(JSMT IUUQ SBJMTHJSMTDPN u$SBGUFEXJUIFYDJUFNFOUGSPN)FMTJOLJ 'JOMBOEu'PMMPXVTPO5XJUUFS IUUQTUXJUUFSDPNSBJMTHJSMT BOE'BDFCPPL IUUQTXXXGBDFCPPLDPNSBJMTHJSMT   
  66. 5JQT։ൃ؀ڥʹ΋.Z42-Λར༻ ͍ͨ͠  

  67. ιʔείʔυΛमਖ਼ͯ͠ίϛοτ͠Α͏ > brew cask install sequel-pro # MySQL؅ཧπʔϧͷΠϯετʔϧ > brew

    install mysql-client > brew services mysql start # MySQLͷىಈ > brew services list ɹɹɹl.Z42-zlσʔλϕʔεzl4FRVFM1SPz  
  68. .Z42-ʹ઀ଓ͢ΔϢʔβΛ࡞੒͢Δ > mysql -uroot mysql> CREATE USER myuser@localhost identified with

    mysql_native_password by ‘mypass'; mysql> exit > ɹɹɹl.Z42-zlσʔλϕʔεzl4FRVFM1SPz   w ࠷৽ͷ.Z42-Ͱ͸σϑΥϧτͷೝূํ͕ࣜDBDIJOH@TIB@QBTTXPSEͱͳ͓ͬͯΓ4FRVFM1SPͳͲ͕ ରԠ͍ͯ͠ͳ͍ͨΊɺ.Z42-ҎલͰར༻͞Ε͍ͯͨNZTRM@OBUJWF@QBTTXPSEΛར༻ͨ͠ϢʔβΛ࡞ ੒͍ͯ͠·͢
  69. 3VCZPO3BJMTΛ࢖͏લͷલ४උ σʔλϕʔεͷ࡞੒ w4QPUMJHIUͰʮ4FRVFM1SPʯΛݕࡧͯ͠&OUFSىಈ  

  70. 3VCZPO3BJMTΛ࢖͏લͷલ४උ σʔλϕʔεͷ࡞੒ wࠨԼͷ ϘλϯΛԡͯ͠৽ن઀ଓઃఆΛ࡞੒  

  71. 3VCZPO3BJMTΛ࢖͏લͷલ४උ σʔλϕʔεͷ࡞੒ w઀ଓ৘ใΛೖྗ   ઌ΄Ͳ࡞੒ͨ͠Ϣʔβ໊ͱύεϫʔ υΛೖྗ NZVTFSNZQBTT

  72. 3VCZPO3BJMTΛ࢖͏લͷલ४උ σʔλϕʔεͷ࡞੒ w઀ଓ৘ใͰ͖ͨΒσʔλϕʔεΛͭ௥Ճʢ։ൃ༻ͱςετ༻ʣ ɹɹɹσʔλϕʔε࡞੒.Z42-  

  73. 3VCZPO3BJMTΛ࢖͏લͷલ४උ σʔλϕʔεͷ࡞੒ wIPTDPOͱ͍͏໊લͷ։ൃ༻σʔλϕʔεΛ࡞੒  

  74. 3VCZPO3BJMTΛ࢖͏લͷલ४උ σʔλϕʔεͷ࡞੒ wIPTDPO@UFTUͱ͍͏໊લͷςετ༻σʔλϕʔεΛ࡞੒ wࠓճ͸࢖͍·ͤΜ  

  75. 5JQT4FRVFM1SP͕ͲͪΒͷσʔλϕʔεΛݟ͍ͯΔ͔ wϝχϡʔͷ্ͷํʹද͕ࣔ͋Γ·͢  

  76. σʔλϕʔεͷ઀ଓઃఆΛ͠Α͏ default: &default adapter: mysql2ɹ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5

    } %> timeout: 5000 development: <<: *default ɹusername: root database: hoscon host: 127.0.0.1 test: <<: *default username: root database: hoscon_test host: 127.0.0.1 production: <<: *default database: [ϚωΫϥͷϓϩδΣΫτը໘Λ֬ೝ] username: [ϚωΫϥͷϓϩδΣΫτը໘Λ֬ೝ] production: <<: *default database: [ϚωΫϥͷϓϩδΣΫτը໘Λ֬ೝ] username: [ϚωΫϥͷϓϩδΣΫτը໘Λ֬ೝ] password: [ϝϞͨ͠σʔλϕʔεͷύεϫʔυ] host: [ϚωΫϥͷϓϩδΣΫτը໘Λ֬ೝ]