Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
kawasakirb053
Search
masaru-tech
October 26, 2017
0
5.6k
kawasakirb053
辛かった愚痴スライドです
masaru-tech
October 26, 2017
Tweet
Share
More Decks by masaru-tech
See All by masaru-tech
Sidekiqでクラスターモードは使えるのか? / kawasakirb_060
masarutech
0
830
stimulusの感触
masarutech
0
48
kawasakirb051
masarutech
0
520
「はやい、やすい、うまい?」React Native
masarutech
1
630
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
225
10k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
How GitHub (no longer) Works
holman
316
140k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
[RailsConf 2023] Rails as a piece of cake
palkan
58
6.2k
Six Lessons from altMBA
skipperchong
29
4.1k
Practical Orchestrator
shlominoach
190
11k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
9
1k
Agile that works and the tools we love
rasmusluckow
331
21k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
Transcript
ॳΊͯͷRailsόʔδϣϯΞοϓ͕ ਏͯ͘ɺπϥͯ͘ɺͭΒ͔ͬͨ kawasaki.rb#053 @MasaruTech
ࣗݾհ • MasaruTechʢtwitterʣ • େఉ কʢ͓͓ɹ·͞Δʣ • ීஈRailsΛ͓ͬͯࣄ͍ͯ͠ΔSIer
ॳΊͯࣄͰͬͨRailsͷϝʔδϟʔ όʔδϣϯΞοϓ͕ਏ͔ͬͨΜͰɺ kawasaki.rbͰు࿐͍ͤͯͩ͘͞͞
࣍ • ਏ͔ͬͨᶃ • ਏ͔ͬͨᶄ • ਏ͔ͬͨᶅ • ൪֎ฤ
ਏ͔ͬͨᶃ
params͕ ActionController::Parameters ΦϒδΣΫτʹ
strong parameterରԠΛ ͪΌΜͱ͍ͬͯͳ͍Օॴ͕ɺɺɺ XxxApi.search(params[:filters])Έ͍ͨʹࡶʹ͍ͬͯ ͨͱ͜Ζ͕ɺɺɺ େମͪΌΜͱstrong parameterରԠ͍ͯ͠Δ&ςετ Ͱ͔͕ͬͨɺAPIαʔόʔͱͷ࿈ܞՕॴελϒԽ͞ ΕͯΔͷͰ࣮ࡍʹಈ͔ͯ͠ݟΔ·Ͱؾ͔ͮͳ͍
ਏ͔ͬͨᶄ
Rails4.2→5.0্͛ͨޙ େྔʹग़Δ Deprecation Warning RDEPRECATION WARNING: Using positional arguments in
functional tests has been deprecated,ɹin favor of keyword arguments, and will be removed in Rails 5.1.
ςετίʔυͷॻ͖ํ͕มΘΔɻɻ get :show, { id: 1 }, nil, { notice:
"This is a flash message" } ↓ keywordҾΛར༻ͨ͠ελΠϧʹͳΔʂʂ get :show, params: { id: 1 }, flash: { notice: "This is a flash message" }, session: nil
ͼ͜Δࣗ༝ͳه๏ • get :index, {name: 'tom', age: 31} • get
:index, name: 'tom', age: 31 • get ‘index’, {name: 'tom', age: 31} • get :index, test_params ͳͲͳͲ
֖Λ։͚ͯΈΕ ࠓճͷRails5ͷόʔδϣϯΞοϓରԠͰɺ spec/controllersͷมߋ84%ʂʂ ͓ͦΒ͘ɺLintίʔυϨϏϡʔ͕ͪΌΜͱͯ͠ ͍Δօ͞Μͷͱ͜ΖͰਏ͘ͳ͍Ͱ͠ΐ͏ʂ
ਏ͔ͬͨᶅ
x3
RailsΞϓϦ͕3ͭ ࠓؔΘ͍ͬͯΔͷɺRailsΞϓϦ3ͭͰߏ͞ Ε͍ͯΔͷͰɺ͜ͷਏ͔ͬͨ࡞ۀΛ3ճΓ·͠ ͨ
൪֎ฤ
activerecord_session-storeͱ config/initializers/ new_framework_defaults.rb
activerecord_session-storeΛ͍ͬͯΔͱ config/initializers/new_framework_defaults.rbͰ Rails.application.config.active_record.belongs_t o_required_by_default=false Λࢦఆ্ͯ͠ॻ͖͞Εͳ͍ɺɺɺ
ݪҼ http://y-yagi.tumblr.com/post/150899354290/rails ΑΓ RailsͷinitializersgemͷಡΈࠐΈޙʹ࣮ߦ͞Ε·͢ɻ ͦͷͨΊɺgem ͷதͰActiveRecordΛࢀর͍ͯ͠Δ(ActiveRecord::Baseʹରͯ͠module ΛՃ͍ͯͨ͠Γ͢Δ)ɺ͔ͭɺదͳܗͰActiveRecordΛࢀর͍ͯ͠ͳ ͍߹ɺActiveRecord::BaseͷॳظԽॲཧ͕ͦͷλΠϛϯάͰߦΘΕͯ ͠·͍ɺinitializersͰઃఆ͢Δલʹbelongs_to_required_by_defaultͷ ͕ઃఆ͞Εͯ͠·͍·͢(belongs_to_required_by_defaultͷॳظnil
ͳͷͰɺ্هͷΑ͏ʹnil͕දࣔ͞ΕΔ)