Upgrade to Pro — share decks privately, control downloads, hide ads and more …

クラウドxスマフォ時代のRuby on Rails入門

クラウドxスマフォ時代のRuby on Rails入門

1. Ruby言語, Ruby on Railsの紹介
2. Ruby on Rails で簡単なWebアプリを作る
3. 出来たWebアプリをクラウドにデプロイ
4. Webアプリをスマフォ用ブラウザーに対応する
5.Webアプリをスマフォアプリに対応する
6. RSpec

裕美 吉田

July 23, 2014
Tweet

More Decks by 裕美 吉田

Other Decks in Programming

Transcript

  1. &:0⒏DF։ൃ 8FC 8 w ΞδΞϦʔάΞΠεϗοέʔ wIUUQXXXBMIPDLZKQ wνʔϜɾબखͷ੒੷ूܭ w1FSMಠࣗϑϨʔϜϫʔΫ wΞϩϋύʔΫ wαʔϏεऴྃ

    w4/4 w+BWB4FBTBS wωοτγϣοϓ wIUUQXXXCPSPDPKQ w3BJMTK2VFSZ w34QFD$VDVNCFS w๖͑τʔΫ ੠༏ͱ4LZQF Ͱ͓࿩  wαʔϏεऴྃ w੠༏ͱͷձ࿩༧໿༧໿ w3BJMTK2VFSZ w34QFD
  2. &:0⒏DFڭҭ 10 ίʔε໊ ೔਺ ಺༰ ޮՌ අ༻ 3VCZPO3BJMTೖ ໳ίʔε ೔

    w3VCZݴޠೖ໳ w3VCZPO3BJMTೖ໳ w3VCZPO3BJMT࣮श w3VCZ3VCZPO3BJMTͷ֓ཁ͕ཧղͰ͖Δ wܦݧ๛ͳ։ൃऀͰ͋Ε͹ɺॻ੶౳Λࢀߟʹ 3VCZPO3BJMTͷ։ൃ͕࢝ΊΒΕΔ ສԁਓ ໊Ҏ্Ͱड ߨ͍ͩ͘͞ 3VCZPO3BJMTඪ ४ίʔε ೔ w3VCZݴޠೖ໳ɺ3VCZ࣮ફϓϩάϥϛϯά w3VCZݴޠ࣮श w3VCZPO3BJMTೖ໳ɺ3VCZPO3BJMT࣮ફ։ൃ w3VCZPO3BJMT࣮श w3VCZ3VCZPO3BJMT͕ཧղͰ͖Δ w3VCZPO3BJMT։ൃϓϩδΣΫτʹϓϩάϥ Ϛʔͱͯ͠ࢀՃͰ͖Δ ສԁਓ 3VCZPO3BJMTప ఈίʔε ೔ w3VCZݴޠೖ໳ɺ3VCZ࣮ફϓϩάϥϛϯά w3VCZݴޠ࣮श w3VCZPO3BJMTೖ໳ɺ3VCZPO3BJMT࣮ફ։ൃ w3VCZPO3BJMT࣮श w࣮༻ΞϓϦͷ։ൃԋश w3VCZ3VCZPO3BJMT͕ཧղͰ͖Δ w3VCZPO3BJMTΛ࢖ͬͨϓϩδΣΫτͷઃ ܭɾ։ൃ͕࢝ΊΒΕΔ ສԁਓ 3VCZPO3BJMT
  3. ࣜ ଞͷݴޠͱ΄΅ಉ͡ 29 a = 2 + (3 * 4)!

    s = “abc” + “def”! b = a > 20! x += 3! n++ ++ɺ-- ͸ແ͍
  4. ੍ޚจ จ๏͸ҧ͏͕ߟ͑ํ͸ಉ͡ ؆ܿͳจ๏ 30 if a > 0! b =

    1! else! b = 0! a = -a! end s = 0! while n > 0! s = s + n! n = n - 1! end
  5. ؔ਺ ϝιου ؆ܿͳจ๏ 31 def fact(n)! if n == 0!

    1! else! fact(n - 1) * n! end! end n = fact(5)! m = fact 4
  6. ΦϒδΣΫτࢦ޲ 32 จ๏͸ҟͳΔ͕ɺجຊ͸+BWB౳ͱ΄΅ಉ͡ class TwoNumber! def initialize(a, b)! @a =

    a; @b = b! end! def add! @a + @b! end! end tw = TwoNumber.new(3, 4)! a = tw.add()
  7. ࣮૷Λڞ༗ग़དྷΔ 36 NJYJO module Double! def double! self * 2!

    end! end class String! include Double! end! class Number! include Double! end 3.double # => 6! “ab”.double # => “abab”
  8. ΠςϨʔλʔ &OVNFSBCMF 39 a = [1,2,3,4]! b = []! for

    n in a! if n > 2! b << n ! end! end a = [1,2,3,4]! b = a.select {|n| n > 2}
  9. ϒϩοΫ 40 def times(n)! for i in 1..n! yield(n)! end!

    end > times(3) {|n| puts n }! 1! 2! 3
  10. 45 ʮ++6($SPTT$PNNVOJUZ$POGFSFODF'BMMͷʰ+BWB͔Β3VCZ΁ʱɾΞϯυɾφ΢ʯ ΑΓɺҰ෦Ճච Patterns of Enterprise Application Architecture Extreme Programming

    Explained -- Embrace Change ୡਓϓϩάϥϚʔ γεςϜ։ൃͷ৬ਓ͔Β໊ঊ΁ͷಓ 3VCZPO3BJMTͷഎܠ Programming Ruby: The Pragmatic Programmer's Guide
  11. +BWB ୈҰੈ୅ϑϨʔϜϫʔΫ ͷ ։ൃελΠϧ ΞʔΩςΫνϟʔͷܾఆ ߴ͍ٕज़εΩϧ ࣮຿ܦݧ ઃܭηϯε 51 ࡉ෼Խ͞Εͨ࢓༷

    ͷ࣮૷ ௿͍ٕज़εΩϧ ୯७࡞ۀత ΞʔΩςΫτ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ϓϩάϥϚʔ ࢓༷ॻ น
  12. SBJMTίϚϯυ rails new ϓϩδΣΫτ! ৽نϓϩδΣΫτͷ࡞੒ rails g ςʔϒϧ ΧϥϜ:ܕ …!

    ςʔϒϧͱͦΕΛѻ͏ίʔυͷ࡞੒ rails s! αʔόʔͷىಈ rails c! ։ൃίϯιʔϧ 61
  13. 62 BQQϓϩάϥϜɺৄࡉ͸࣍ϖʔδ CJO։ൃπʔϧ MJCϥΠϒϥϦʔ DPOpHઃఆ ECσʔλϕʔεؔ܎ QVCMJDελςΟοΫͳ)5.-ͳͲ TQFD UFTUςετίʔυ WFOEPS͍Ζ͍Ζ

    ྺ࢙తͳཧ༝  MPHϩάϑΝΠϧ UNQҰ࣌తͳϑΝΠϧͳͲ (FNpMFHFNϥΠϒϥϦʔͷ؅ཧ ΞϓϦͷσΟϨΫτϦʔߏ଄
  14. 3&45GVMͳίϯτϩϥʔ 63-͸ϦιʔεΛݱ͢ ૢ࡞͸ϝιου (&5 1045 1"5$) %&-&5& Λ࢖͏ SBLFSPVUFTίϚϯυͰදࣔ 66

    ૢ࡞ ϝιου 63- ॲཧ Ұཡ (&5 IUUQTFSWFSUPEPT JOEFY औಘ (&5 IUUQTFSWFSUPEPT TIPX ߋ৽ 1"5$) IUUQTFSWFSUPEPT VQEBUF ొ࿥ 1045 IUUQTFSWFSUPEPT DSFBUF ࡟আ %&-&5& IUUQTFSWFSUPEPT EFTUSPZ
  15. Α͘࢖͏(FN 75 (FN ػೳ ,BNJOBSJ Ұཡͷϖʔδϯά $BSSJFS8BWF ը૾ͳͲͷΞοϓϩʔυ 1BQFSDMJQ ը૾ͳͲͷΞοϓϩʔυ

    0NJOJ"VUI 5XJUUFS 'BDFCPPLͳͲͷΛ࢖͏ϩάΠϯೝূ %FWJTF ࣗલ%#Λ࢖͏ϩάΠϯೝূɺଟػೳ 3BJMT"ENJO 3%#σʔλͷ؅ཧը໘
  16. 6*

  17. )FSPLVσϓϩΠखॱ  IFSPLVπʔϧͷμ΢ϯϩʔυɾΠϯετʔϧ  (FNpMFͷमਖ਼ 3. bundle install! 4. heroku

    create! 5. git commit! 6. git push heroku master! 7. heroku run rake db:migrate 84
  18. "84౳΁ͷσϓϩΠखॱ 85  "84ʹαʔόʔΛ࡞੒  αʔόʔʹ3VCZ 3%#ʜͷΠϯετʔϧɻ ͕͜͜େมʂ࠷ۙ͸$IFG౳ͰࣗಈԽ͢Δ  DBQJTUSBOPͷΠϯεʔϧ

     DBQJTUSBOPͷઃఆϑΝΠϧ࡞੒ɾมߋ 5. git commit! 6. git push origin master! 7. cap deploy!  ্ख͘ߦ͔ͳ͚Ε͹ ΁໭Δ
  19. +40/ͷग़ྗ Ϩεϙϯε͸)5.-Ҏ֎ʹ+40/౳Λग़ྗͰ ͖Δ 93 <p>! <strong>Name:</strong>! <%= @post.user.name %>! </p>!

    <p>! <strong>Caption:</strong>! <%= @post.caption %>! </p> json.extract! @post, :id, :name, :caption TIPXIUNMFSC TIPXKTPOKCVJMEFS
  20. 96 ίʔυͷ࡞੒ ςεςΟϯά NO YES ςετίʔυͷ࡞੒ ίʔυͷ࡞੒ NO YES ςετίʔυͷ࣮ߦ

    ઃܭ ઃܭ σόοΫ ैདྷͷ։ൃελΠϧ ̩̙̙ͷ։ൃελΠϧ ͜͜Λ܁Γฦ͢͜ ͱͰ։ൃΛਐΊΔ جຊతʹ͸ Ұํ޲ͷྲྀΕ ඞཁͳΒςετίʔ υͷ࡞੒ 0, 0, 5%%ςετۦಈ։ൃ