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.4k
kawasakirb053
辛かった愚痴スライドです
masaru-tech
October 26, 2017
Tweet
Share
More Decks by masaru-tech
See All by masaru-tech
Sidekiqでクラスターモードは使えるのか? / kawasakirb_060
masarutech
0
660
stimulusの感触
masarutech
0
43
kawasakirb051
masarutech
0
420
「はやい、やすい、うまい?」React Native
masarutech
1
570
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
155
14k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
The Mythical Team-Month
searls
216
42k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.1k
Documentation Writing (for coders)
carmenintech
60
3.9k
In The Pink: A Labor of Love
frogandcode
138
21k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
244
20k
Mobile First: as difficult as doing things right
swwweet
216
8.6k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
322
20k
Bash Introduction
62gerente
604
210k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
9
8.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͕දࣔ͞ΕΔ)