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.5k
kawasakirb053
辛かった愚痴スライドです
masaru-tech
October 26, 2017
Tweet
Share
More Decks by masaru-tech
See All by masaru-tech
Sidekiqでクラスターモードは使えるのか? / kawasakirb_060
masarutech
0
750
stimulusの感触
masarutech
0
45
kawasakirb051
masarutech
0
470
「はやい、やすい、うまい?」React Native
masarutech
1
590
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1030
460k
Bash Introduction
62gerente
608
210k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
228
52k
Scaling GitHub
holman
458
140k
How STYLIGHT went responsive
nonsquared
95
5.2k
How to Think Like a Performance Engineer
csswizardry
19
1.1k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
37
1.8k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
The Power of CSS Pseudo Elements
geoffreycrofte
72
5.3k
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͕දࣔ͞ΕΔ)