Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

Ganbaranai wo ganbaru

makicamel
March 02, 2021

Ganbaranai wo ganbaru

- 2021.03.02. ANDPAD TechLive #3 プロダクトの成長と共に歩むRails開発改善の歴史と未来

makicamel

March 02, 2021
Tweet

More Decks by makicamel

Other Decks in Programming

Transcript

  1. class Users::GreetingsController < Users::ApplicationController before_action :set_greeting before_action :energy_required def set_greeting

    @greeting = current_user.greeting end before_action :depressed_greeting_required, only: [:destroy] def depressed_greeting_required raise UnauthorizedError unless @greeting.depressed? end # νϟοτͰͷΈར༻ include Common::Chats::GreetingsController def greeting_permissions chat_permissions end end ݟ௨͠ͷ ѱ͍Ϋϥε
  2. class Greeting < ApplicationRecord include GreetingRelation # relation include GreetingScope

    # scope # enum include State # ֤greetingͷ࡞੒ include ForActionAccount include ForActionOrder # include ForActionWork include ForActionCustomer # ... end ϞδϡʔϧͰޡຐԽ͞ΕͨϑΝοτΫϥε
  3. class Admin::GreetingsController < Admin::ApplicationController AdminRoutes::STRUCTURES.each_pair do |k, v| define_method k

    do # ... end v.each_pair do |kk, vv| define_method "#{kk}_hi" do # ... end define_method “#{kk}_goodbye" do # ... end end end end ϝλϓϩ
  4. class Users::GreetingsController < Users::ApplicationController before_action :set_greeting before_action :energy_required def set_greeting

    @greeting = current_user.greeting end before_action :depressed_greeting_required, only: [:destroy] def depressed_greeting_required raise UnauthorizedError unless @greeting.depressed? end # νϟοτͰͷΈར༻ include Common::Chats::GreetingsController def greeting_permissions chat_permissions end end ݟ௨͠ͷѱ͍ ίϯτϩʔϥ
  5. class Users::GreetingsController < Users::ApplicationController before_action :set_greeting before_action :energy_required def set_greeting

    @greeting = current_user.greeting end before_action :depressed_greeting_required, only: [:destroy] def depressed_greeting_required raise UnauthorizedError unless @greeting.depressed? end # νϟοτͰͷΈར༻ include Common::Chats::GreetingsController def greeting_permissions chat_permissions end end •ΈͮΒ͍ •ͲΕ͕ΞΫγϣϯʁ •͍ͭͲͷίʔϧόοΫ͕ൃՐ͢Δͷʁ •͜ͷϞδϡʔϧ͸Ұମ…ʁ •chat_permissionsͬͯԿ
  6. •ಛʹ JavaScript Λհͨ͠ར༻Օॴͷಛఆ͕ࠔ೉ •AngularJS, Vue.js, jQuery ͕ಉϦϙδτϦͰڞଘ •angularjs-rails-resource ͷࣗ༝౓͕ڟѱ •Өڹൣғͷ֬ೝʹ͕͔͔࣌ؒΔ

    •ͲΕ͚ͩௐ΂ͯ΋֬৴͕࣋ͯͳ͍ ༻్ෆ໌ͳίϯτϩʔϥ 'JOF-JOF1SPUPUZQJOHBOHVMBSKTSBJMTSFTPVSDF IUUQTHJUIVCDPN'JOF-JOF1SPUPUZQJOHBOHVMBSKTSBJMTSFTPVSDF
  7. •before •͕Μ͹ͬͯ grep ͢Δͷ͸ർΕΔ͠࿙ΕΔ •after •ϝιουΛΦʔόʔϥΠυ •ಛఆ৚݅Ͱݺ͹ΕͨΒ Bugsnag ʹ௨஌ͯ͠ super

    ͢Δ ※ ςετͰ΋͋Δఔ౓ݕ஌Ͱ͖Δ͚Ͳ ɹςετ͕ͳ͍ͱ͜ΖͰݺ͹ΕΔՄೳੑ΋͋ΔͷͰຊ൪ಋೖ ͕Μ͹Βͳ͍
  8. 2 ஈ֊ϦϦʔε class ApplicationController < ActionController::Base private # ... #

    վम࣌ʹ҆શʹมߋΛ͢ΔͨΊͷϝιου # ྫ֎ൃੜ࣌ʹຊ൪؀ڥͰ͸௨஌Λૹͬͯݕূ͢ΔͨΊʹར༻͢Δ # 1ʙ2िؒఔ౓༷ࢠΛݟͯ໰୊͕ͳ͚Ε͹ϒϩοΫΛ֎͢ def temporary_ignore_error yield rescue => e if ::Rails.env.production? ::Bugsnag.notify(e) else raise e end end end
  9. ·ͱΊ •࣌ؒΛ࡞Δ •3 ਓʹ͸ͳΕͳ͍͚Ͳɺ࡞ۀ࣌ؒΛ 1/3ʢҎԼʣʹ͸Ͱ͖Δ •εΫϦϓτͱ͔ Rails ͱ͔௨஌ͱ͔ esa ͱ͔ςϯϓϨʔτͱ͔ʹ࢓

    ࣄͯ͠΋Β͏ •ٕज़తʹ೉͍͜͠ͱ͸΍͍ͬͯͳ͍ •;ͭ͏ʹ Ruby / Rails ͷίʔυ͕ॻ͚Ε͹Ͱ͖Δ͜ͱ͹͔Γ •ʮ͕Μ͹Βͳ͍ʯ͜ͱΛ͕Μ͹Δ