7年目を迎えたRails アプリケーションの傾向と対策/Rails Developers Meetup 2019 Day1

Ff07ba188f0dccc30e7a90a5ebd1a386?s=47 taogawa
March 22, 2019

7年目を迎えたRails アプリケーションの傾向と対策/Rails Developers Meetup 2019 Day1

Rails Developers Meetup 2019でお話した「7年目を迎えたRails アプリケーションの傾向と対策」のスライドです。

Ff07ba188f0dccc30e7a90a5ebd1a386?s=128

taogawa

March 22, 2019
Tweet

Transcript

  1. 12.

    ͷιϦϡʔγϣϯͰ໰୊ͷΛղܾͰ͖Δ w $P$ ઃఆΑΓن໿ Ͱ൥ࡶͳઃఆϑΝΠϧΛল ུ w .PEFMͱςʔϒ ϧͷಉҰࢹ "DUJWF3FDPSEύλʔ

    ϯ ͰϚοϐϯάΛγϯϓϧʹ w ͳͲͳͲɾɾɾ3BJMTͷ͢͹Β͠͞ͷͻͱͭ͸ɺ ͦͷେ୾ʹׂΓ੾ͬͨઃܭࢥ૝
  2. 15.

    ͍͔ͭ͘ͷʮϨʔϧΛͪΐͬͱ͸ͣΕͨʯ ఆ൪ύλʔϯ͕͋Δ w ංେԽͨ͠"DUJWF3FDPSEϞσϧΛϦϑΝΫλϦϯά͢ Δͭͷํ๏ w IUUQTUFDISBDIPCQTJODKQ IBDIJ@@ ຋༁ 

    w IUUQTDPEFDMJNBUFDPNCMPHXBZTUP EFDPNQPTFGBUBDUJWFSFDPSENPEFMT ݪจ  w ೥Ҏ্લ͚ͩͲݹͼͳ͍ఆ൪ͷهࣄ
  3. 30.

    7JFX.PEFM 1SFTFOUFS ͷఆٛ class ProductPresenter # ... def price discount?

    ? @product.discount_price : @product.price end def discount? @user.paid_member? && @product.member_only_discount? end end
  4. 35.
  5. 44.

    Α͋͘Δ֬ೝνΣοΫ # view = form_for(@event, url:foo_path(@event), method: 'patch') do |f|

    = f.hidden_field :event_id = text_area_tag :body = check_box_tag :confirmed # 確認チェック = f.submit "予約をキャンセル" # controller # パラメータのチェックが複数あると見通しが悪くなる if params[:confirmed] == "1" # ... else # ... end
  6. 47.

    $POUSPMMFS͕͖ͬ͢Γʂ # before if params[:confirmed] == "1" # ... else

    # ... end # after @event_cancellation_form = EventCancellationMessageForm.new(cancellation_message_params) # パラメータチェックが複数あってもFormModel内で処理できる if @event_cancellation_form.valid? # ... end
  7. 49.

    ͞ΒʹɺԠ༻΋ར͘ΜͰ͢ # view = form_for @bulk_schedule_form, url:schedules_path, method: "post" do

    |f| = f.fields_for :schedules do |s| # ... =f.submit "一括登録" # form_model class BulkScheduleForm includes Activemodel::Model attr_accessor: schedules # ... def schedule_attributes=(attributes) self.schedules = attributes.map do |schedule_attributes| schedule.new(schedule_attributes) end end end
  8. 52.
  9. 59.

    4FSWJDF0CKFDUͷఆٛ # service_object class EventCreateService def initialize(params) # ... end

    def call # ... end end # controller service = EventCreateService.new(event_params) service.call if service.success? # ... end
  10. 63.
  11. 66.

    ͋ͳͨͷαʔϏε͸ͲͷαʔϏεʁ w ͦ΋ͦ΋&SJD&WBOTͷ%%%ຊͰͷαʔϏεఆ͕ٛ෯޿͍ w ΞϓϦέʔγϣϯαʔϏε w υϝΠϯαʔϏε w ΠϯϑϥετϥΫνϟαʔϏε w

    1PG&""ͷαʔϏεϨΠϠʔ w ͍͍ײ͡ͷศརϝιουͱͯ͠4FSWJDF͕࢖ΘΕΔ w ͜ͷ఺Λҙ͍ࣝͯ͠ͳ͍ͱɺ࿩͕͔Έ߹Θͳ͍
  12. 72.