Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
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
820
stimulusの感触
masarutech
0
47
kawasakirb051
masarutech
0
510
「はやい、やすい、うまい?」React Native
masarutech
1
620
Featured
See All Featured
Music & Morning Musume
bryan
46
6.7k
Designing Experiences People Love
moore
142
24k
Scaling GitHub
holman
462
140k
How to train your dragon (web standard)
notwaldorf
96
6.2k
Into the Great Unknown - MozCon
thekraken
40
2k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.8k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Gamification - CAS2011
davidbonilla
81
5.4k
Building an army of robots
kneath
306
46k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.4k
Testing 201, or: Great Expectations
jmmastey
45
7.6k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.6k
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͕දࣔ͞ΕΔ)