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

Ruby on Rails と Django を比較してみる

free_world21
September 29, 2024

Ruby on Rails と Django を比較してみる

TokyuRuby会議15
https://tokyurb.connpass.com/event/330007/

で使用した発表用スライドです

free_world21

September 29, 2024
Tweet

More Decks by free_world21

Other Decks in Programming

Transcript

  1. ▪ খྛޛ࢙ʢখྛϊΤϧʣ ▪ ຊۀɿϒϧʔϞূ݊גࣜձࣾऔక໾$50 – ถࠃגɾถࠃ&5'ઐۀͷ௕ظࢿ࢈ܗ੒ಛԽ ܕͷ౤ࢿΞϓϦΛ࡞ͬͯΔ'JOUFDIελʔ τΞοϓ ▪ ೥

    ΄ͲϑϦʔϥϯεΤϯδχΞ – ్தࣄۀձࣾͷதͷਓ΋΍ͬͨ ▪ ʙɿϒϧʔϞূ݊גࣜձࣾΛ૑ۀ ▪ झຯɿཱྀߦɾੈքͷίϫʔΩϯάεϖʔεΊ͙ ΓʢϫʔέʔγϣϯతͳԿ͔ʣ @free_world21 THE FARM@NY CARR WORKPLACE@Chicago https://bloomo.co.jp/
  2. %KBOHPͱ͸ʢଞͷϑϨʔϜϫʔΫͱൺֱͯ͠ʣ ▪ 1ZUIPO੡ͷ'VMMTUBDLϑϨʔϜϫʔΫ ▪ 3VCZPO3BJMTͱ΄΅ಉظʁ %KBOHP 3VCZPO3BJMT &YQSFTTKT /FTUKT 

    )POP౳ ʢOPEFKTܥϑϨʔϜ ϫʔΫʣ (JO FDIP౳ ʢ(PMBOHܥϑϨʔ ϜϫʔΫʣ ϓϩάϥϛϯάݴޠ 1ZUIPO 3VCZ 5ZQF4DSJQU (PMBOH *OJUJBMSFMFBTF     ϑϨʔϜϫʔΫࢤ޲ 'VMMTUBDL 'VMMTUBDL NJDSPGSBNFXPSL NJDSPGSBNFXPSL 03. %KBOHP03. "DUJWF3FDPSE 5ZQF03. 1SJTNB౳ ࣗ࡞ (03.౳ NJHSBUJPO %KBOHPNJHSBUJPO "DUJWF3FDPSE.JHSBUJPO ECNJHSBUF౳ HPMBOHNJHSBUF HPPTF ςετ %KBOHPUFTU QZUFTU NJOJUFTU STQFD +FTU +BTNJOF౳ CVJMUJO ܕαϙʔτ 5ZQF)JOUT CVJMUJO 3#4 CVJMUJO ʢͨͩ͠ίϯύΠϧΦ ϓγϣϯଟ਺ʣ CVJMUJO
  3. %KBOHPͱ͸ʢଞͷϑϨʔϜϫʔΫͱൺֱͯ͠ʣ ▪ 1ZUIPO੡ͷ'VMMTUBDLϑϨʔϜϫʔΫ ▪ 3VCZPO3BJMTͱ΄΅ಉظʁ %KBOHP 3VCZPO3BJMT &YQSFTTKT /FTUKT 

    )POP౳ ʢOPEFKTܥϑϨʔϜ ϫʔΫʣ (JO FDIP౳ ʢ(PMBOHܥϑϨʔ ϜϫʔΫʣ ϓϩάϥϛϯάݴޠ 1ZUIPO 3VCZ 5ZQF4DSJQU (PMBOH *OJUJBMSFMFBTF     ϑϨʔϜϫʔΫࢤ޲ 'VMMTUBDL 'VMMTUBDL NJDSPGSBNFXPSL NJDSPGSBNFXPSL 03. %KBOHP03. "DUJWF3FDPSE 5ZQF03. 1SJTNB౳ ࣗ࡞ (03.౳ NJHSBUJPO %KBOHPNJHSBUJPO "DUJWF3FDPSE.JHSBUJPO ECNJHSBUF౳ HPMBOHNJHSBUF HPPTF ςετ %KBOHPUFTU QZUFTU NJOJUFTU STQFD +FTU +BTNJOF౳ CVJMUJO ܕαϙʔτ 5ZQF)JOUT CVJMUJO 3#4 CVJMUJO ʢͨͩ͠ίϯύΠϧΦ ϓγϣϯଟ਺ʣ CVJMUJO ࣗ෼ͰબͿඞཁ͕ͳ͍ ʢ೴ࢮͰ։ൃͰ͖Δʣ ࣗ෼ͰબͿඞཁ͕͋Δʂʂ
  4. %KBOHPͷಛ௃ɿ.75 .PEFM7JFX5FNQMBUF ▪ %KBOHP͸.75 .PEFM7JFX5FNQMBUF Ͱ͋Δ ▪ 3BJMT͸.7$ .PEFM7JFX$POUSPMMFS %KBOHP

    3VCZPO3BJMT Ϗδωεϩδο Ϋ૚ ݺͼํ .PEFM .PEFM هड़ݴޠ 1ZUIPO 3VCZ ಛ௃ ͭͷ.PEFM͕%#ͷςʔϒϧͱରԠ ͭͷ.PEFM͕%#ͷςʔϒϧͱରԠ ೖग़ྗ૚ ݺͼํ 7JFX $POUSPMMFS هड़ݴޠ 1ZUIPO 3VCZ ಛ௃ 3BJMTͰ͍͏ͱ͜Ζͷ$POUSPMMFSͱࢥͬͯ͘Εͯ0, ׂѪ දࣔ૚ ݺͼํ 5FNQMBUF 7JFX هड़ݴޠ %KBOHPUFNQMBUFMBOHVBHF &3# )BNM౳ ಛ௃ 1ZUIPOεΫϦϓτ͸ຒΊࠐΊͳ͍ͷͰɺ ϏδωεϩδοΫΛهड़͢Δ͜ͱ͸΄΅ෆՄೳ 3VCZεΫϦϓτ΋ຒΊࠐΊΔͷͰ ͋Δఔ౓ϏδωεϩδοΫ΋ॻ͚Δ
  5. %KBOHPͷಛ௃ɿ.75 .PEFM7JFX5FNQMBUF ▪ %KBOHP͸.75 .PEFM7JFX5FNQMBUF Ͱ͋Δ ▪ 3BJMT͸.7$ .PEFM7JFX$POUSPMMFS %KBOHP

    3VCZPO3BJMT Ϗδωεϩδο Ϋ૚ ݺͼํ .PEFM .PEFM هड़ݴޠ 1ZUIPO 3VCZ ಛ௃ ͭͷ.PEFM͕%#ͷςʔϒϧͱରԠ ͭͷ.PEFM͕%#ͷςʔϒϧͱରԠ ೖग़ྗ૚ ݺͼํ 7JFX $POUSPMMFS هड़ݴޠ 1ZUIPO 3VCZ ಛ௃ 3BJMTͰ͍͏ͱ͜Ζͷ$POUSPMMFSͱࢥͬͯ͘Εͯ0, ׂѪ දࣔ૚ ݺͼํ 5FNQMBUF 7JFX هड़ݴޠ %KBOHPUFNQMBUFMBOHVBHF &3# )BNM౳ ಛ௃ 1ZUIPOεΫϦϓτ͸ຒΊࠐΊͳ͍ͷͰɺ ϏδωεϩδοΫΛهड़͢Δ͜ͱ͸΄΅ෆՄೳ 3VCZεΫϦϓτ΋ຒΊࠐΊΔͷͰ ͋Δఔ౓ϏδωεϩδοΫ΋ॻ͚Δ Ұ൪ͷҧ͍
  6. 3JMTͱ%KBOHPͷൺֱɿίϚϯυܥ Ruby on Rails Django project作成 N/A python manage.py startproject

    ceres app作成 rails new diet python manage.py startapp diet 開発サーバ起動 rails s python manage.py runserver コンソール起動 rails console python manage.py shell 任意のコマンド呼び出 し rails(rake) hoge python manage.py hoge DB作成 rails db:create N/A migrationファイル作成 rails g migration … python manage.py makemigrations migration実⾏ rails db:migrate python manage.py migrate
  7. 3JMTͱ%KBOHPͷൺֱɿσʔλϕʔεݺͼग़͠ Ruby on Rails Django 全件取得 Author.all Author.objects.all() ID指定ロード Author.find(123)

    Author.objects.get(id=123) where Author.where(name: ‘hoge’) Author.where(“age >= ?”, 20) Author.where(age: 20..30) Author.where(age: nil) Author.objects.filter(name=‘hoge’) Author.objects.filter(age__gte=20) Author.objects.filter(age__range=(20, 30)) Author.objects.filter(age__isnull=True) 関連呼び出し author.published_books author.publishedbook_set.all() - name: string - age: int, null: true authors - author_id: int - title: string published_books