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

入門 名前

入門 名前

Fujimura Daisuke

March 23, 2019
Tweet

More Decks by Fujimura Daisuke

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ • ౻ଜେհ • גࣜձࣾϚνϚν • Rails ྺ 10 ೥

    • https://twitter.com/ffu_ • https://github.com/fujimura
  2. ࠶ར༻ʹΑΔੜ࢈ੑͷ޲্͸ʮٕज़ʯͷࠜװ • զʑ͸ͳͥ Ruby on Rails ͕ಈ͘ͷ͔஌Βͳ͍͚Ͳ࢖͑Δ • RailsɺMRIɺσʔλϕʔεɺͦͷଞϛυϧ΢ΣΞɺCPU… •

    ࡉ෦Λཧղͤͣʹ࠶ར༻Ͱ͖Δ͜ͱ͕ٕज़ͷఆٛͷͻͱͭ • ͜ΕͰਓྨͷੜ࢈ੑ͸্͕͖ͬͯͨ • ৠؾػؔɺిؾɺίϯϐϡʔλʔ • ϓϩάϥϜ΋ͦͷҰͭ
  3. ͡Ό͋ɺԿ͕Α໊͍લͳͷ • ʰίʔυɾίϯϓϦʔτʱͰௐ΂ͯΈ·ͨ͠ • ʮ໋໊ʹ͓͍ͯ࠷΋ॏཁͳߟྀ͢΂͖఺͸ɺม਺͕දݱ͢Δ΋ͷΛਖ਼֬ʹ ׬શʹݴ͍ද͍ͯ͠Δ͜ͱʯ • McConnell, Steve. Code

    Complete (Kindle Location 6490). Microsoft Press. Kindle Edition) ຋༁͸ஶऀ • ʮਖ਼֬ʯͰʮ׬શʯͳ໊લͬͯͲ͏͍͏ঢ়ଶͰ͔͢ʁ => ॻ͍ͯͳ͍ • Կ͕ྑ໊͍લͳͷ͔ॻ͍ͯͳ͍ͷͰɺߟ͑ͯΈ·ͨ͠
  4. ύλʔϯ 2: ໊લͷҙຯ͕޿͗͢Δ • check ͨ݁͠ՌͲ͏ͳΔͷʁ • login ͍ͯ͠Δͷ͕ਖ਼ʁ͍ͯ͠ͳ͍ͷ͕ਖ਼ʁ •

    ໊લ͔Β͸Θ͔Βͳ͍ • check ͷҙຯ͕޿͗͢Δͷ͕ݪҼ before_action :check_login private def check_login unless current_user redirect_to login_path end; end
  5. User#check_paid ղମ • ͦΕͧΕԼهͷ༷ʹ࣮૷͞Ε͍ͯΕ͹ɺ೰Ή͜ͱ͸ͳ͍͸ͣ • check Λ࢖͏ͷΛ΍ΊΔ͚ͩͰ໊લ͕ྑ͘ͳΓ·͢ class User #

    ࢧ෷͍͕ࡁΜ͔ͩΛ Boolean Ͱฦ͢ def paid? # ... end # ࢧ෷͍͕ࡁΜͰ͍ͳ͍৔߹ϢʔβʔʹΤϥʔ৘ใΛ௥Ճ͢Δ def add_error_if_not_paid # ... end end
  6. ࣙॻ.app • ໊લͷͨΊʹ࠷΋ॏཁͳπʔϧ͸ࣙॻ • Mac OS X ͷ ࣙॻ.app ͸ਆ

    • ͳΜͱӳӳࣙయɺྨޠࣙయɺӳ࿨ࣙయɺ࿨ӳࣙయ͕ɺશ෦ແྉͰೖ͍ͬͯΔ • ʮ؀ڥઃఆʯ͔Β௥ՃͰ͖ΔͷͰɺ·ͩͷํ͸͍·͙͢௥Ճ͠Α͏