Slide 1

Slide 1 text

࿦ཧ࡟আΛ ͠ͳ͍ 2015-08-31 ࿦ཧ࡟আCasual Talks #1 @moro

Slide 2

Slide 2 text

ॾڮګհ(@moro) Kyosuke MOROHASHI

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

఻͍͑ͨ͜ͱ

Slide 6

Slide 6 text

࿦ཧ࡟আͳΜͯ ͳ͔ͬͨ

Slide 7

Slide 7 text

‣࡟আ͍ͯ͠ͳ͍ ‣࡟আ͍ͯ͠ͳ͍ͷͰ࡟আͱ ݺͿ΂͖Ͱͳ͍ɻ ‣ͥΜͥΜ࿦ཧతͰ΋softͰ ΋ͳ͍.

Slide 8

Slide 8 text

࿦ཧ࡟আΛ
 ͨ͘͠ͳΔͱ͖

Slide 9

Slide 9 text

ઈ൛঎඼ʹ
 ࡟আϑϥάΛ෇͚͍ͨ

Slide 10

Slide 10 text

࣮ݱ͍ͨ͜͠ͱ ‣ ઈ൛ͨ͠঎඼Λ࿦ཧ࡟আͯ͠ɺ Ұཡ΍ݕࡧͰදࣔ͞Εͳ͍Α ͏ʹ͍ͨ͠ɻ ‣ ৽͘͠ߪೖ΋Ͱ͖ͳ͍ͨ͘͠ɻ

Slide 11

Slide 11 text

ຊ౰ʹ”࡟আ”ͳͷ͔? ‣աڈʹങͬͨސ٬ͷߪങཤ ྺʹ͸දࣔ͢Δ ‣ച্ूܭͷର৅ʹͳΔ

Slide 12

Slide 12 text

΄Μͱ͏ʹཉ͔ͬͨ͠΋ͷ status = :ઈ൛

Slide 13

Slide 13 text

class Product < AR::Base scope :sellable, -> { where.not(status: :絶版) } end class ProductsController < AppC def index @products = Product.sellable.order(nantoka) end end class Backroom::ProductsController < AppC def index @products = Product.order(kantoka) end end

Slide 14

Slide 14 text

default_scope :sellable 
 ΋ඇਪ঑ɻʮσϑΥϧτʯ ͡Όͳ͍Ͱ͢͠

Slide 15

Slide 15 text

class Order < AR::Base default_scope -> { where(deleted_at: nil } end # 忘れた頃に def clean_old_orders(orders) orders.unscoped.destroy_all # さらに忘れた頃に clean_old_orders(Order.where(company_id: 42))

Slide 16

Slide 16 text

ୀ৬ͨ͠ձһʹ ࡟আϑϥάΛ෇͚͍ͨ

Slide 17

Slide 17 text

࣮ݱ͍ͨ͜͠ͱ ‣ୀձͨ͠ձһ͸ɺ
 ϩάΠϯग़དྷͳ͍Α͏ʹɺ ࿦ཧ࡟আ͍ͨ͠

Slide 18

Slide 18 text

ຊ౰ʹ”࡟আ”ͳͷ͔? ‣ ͦͷձһͷσʔλ͸Ͳ͏ͳΔ? ‣ a: ͥΜͿফ͢ ‣ b: ͦͷ··࢒͢ ‣ c: ಗ໊ͱͯ͠࢒͢ ‣ d: γεςϜϢʔβ΁෇͚ସ͑

Slide 19

Slide 19 text

ຊ౰ʹ”࡟আ”ͳͷ͔? ‣a: ͥΜͿফ͢ ‣ ফ͠·͠ΐ͏!!! ‣ ෆ҆ͳΒඞཁͳͱ͜Ζ͚ͩ ΞʔΧΠϒ

Slide 20

Slide 20 text

ຊ౰ʹ”࡟আ”ͳͷ͔? ‣b: ͦͷ··࢒͢ ‣ ୀձձһΛ status = :ログイ ン不可 ʹ͢Δ
 (status͸ͦΕ͸ͦΕͰ pros/cons ͋Δ΋ͷͷ…) ‣ೝূ৘ใ͚ͩফ͢

Slide 21

Slide 21 text

ຊ౰ʹ”࡟আ”ͳͷ͔? ‣c: ಗ໊ͱͯ͠࢒͢ ‣ݸਓ৘ใͳͲΛফ͢Α͏ɺ ॲཧΛ଍͢

Slide 22

Slide 22 text

ຊ౰ʹ”࡟আ”ͳͷ͔? ‣ d: γεςϜϢʔβ΁෇͚ସ͑ ‣ͦ͏͍͏ॲཧΛ଍͢

Slide 23

Slide 23 text

ຊ౰ʹ”࡟আ”ͳͷ͔? ‣ a: Ҏ֎͸ʮ࡟আʯ͍ͯ͠ͳ͍ ‣ a: Ұॹʹফ͢ ‣ b: ͦͷ··࢒͢ ‣ c: ಗ໊ͱͯ͠࢒͢ ‣ d: γεςϜϢʔβ΁෇͚ସ͑

Slide 24

Slide 24 text

ʮ࿦ཧ࡟আʯͰ͸ͳ͘
 ΍Γ͍ͨ͜ͱʹԊͬͨઃܭΛ

Slide 25

Slide 25 text

อ؅ظݶͷ ա͗ͨσʔλʹ ࡟আϑϥάΛ෇͚͍ͨ

Slide 26

Slide 26 text

࣮ݱ͍ͨ͜͠ͱ ‣ҰఆظؒҎ্ݹ͍σʔλΛ ࿦ཧ࡟আ͠ɺҰཡʹදࣔ͞ Εͳ͍ͨ͘͠ɻ

Slide 27

Slide 27 text

ຊ౰ʹ”࡟আ”ͳͷ͔? ‣ ϩάΛऔͬͯফ͢ɻ ‣ ࡟আͰ͖ͦ͏ɻ ‣ ؂ࠪʹඞཁetcͳͲͳΒ࢒͢ɻ

Slide 28

Slide 28 text

ຊ౰ʹ”࡟আ”ͳͷ͔? ‣ٯʹߟ͑Δɻ ‣ Ұཡʹදࣔ͢Δ߲໨Λ
 ৽͍͠΋ͷ͚ͩʹ͢Δɻ ‣ σʔλྔͷݒ೦ͱɺUXͷ
 ݒ೦͸ͦΕͧΕผͷ໰୊ɻ

Slide 29

Slide 29 text

default_scope と同じ問題 一番最初の画面に出すもの、が デフォルトなわけではない。

Slide 30

Slide 30 text

ͳͥ࿦ཧ࡟আΛ ͢΂͖Ͱͳ͍ͷ͔
 (reprise)

Slide 31

Slide 31 text

‣ࢭΊ͕࣌Θ͔Βͳ͍ɻ ‣ શςʔϒϧʹ࡟আϑϥά ‣ ͭͶʹJOINͯ͠ϑϥάνΣοΫ

Slide 32

Slide 32 text

‣σʔλͷऴΘΓΛ
 ઃܭͰ͖͍ͯͳ͍ɻ ‣ઃܭͰ͖͍ͯͳ͍ͷͰ
 ࢭΊ͕ܾ࣌ΊΒΕͳ͍ɻ

Slide 33

Slide 33 text

ͳͷʹʮ࿦ཧ࡟আʯͰ
 Կ͔ΛݴͬͨงғؾʹͳΔɻ 
 ࢛จࣈख़ޠ͜Θ͍ɻ

Slide 34

Slide 34 text

࿦ཧ࡟আΛ
 ͠ͳ͍

Slide 35

Slide 35 text

‣σʔλͷʮऴΘΓํʯΛ
 ;ͭ͏ʹઃܭ͢Δɻ ‣࢛จࣈख़ޠͰԿ͔Λ
 ݴͬͨؾʹͳΒͳ͍ɻ

Slide 36

Slide 36 text

͋ΘͤͯಡΈ͍ͨ: http://qiita.com/Jxck_/items/156d0a231c6968f2a474

Slide 37

Slide 37 text

‣σʔλͷʮऴΘΓํʯΛ
 ;ͭ͏ʹઃܭ͢Δɻ ‣࢛จࣈख़ޠͰԿ͔Λ
 ݴͬͨؾʹͳΒͳ͍ɻ