5.2
원본: http://guides.rubyonrails.org/5_2_release_notes.html
Ruby on Rails 5.2 릴리즈 노트
레일즈 5.2 하이라이트:
Active Storage
Redis 캐시 저장소
HTTP/2 초기 힌트
Credentials
Content Security Policy
이 릴리즈 노트에는 주요 변경점만 포함됩니다. 더 다양한 변경점과 버그 수정을 보려면 GitHub에서 Rails 메인 저장소의 커밋 목록이나 변경 로그를 확인하세요.
레일즈 5.2로 업그레이드하기
기존 애플리케이션을 업그레이드하기 전에 충분한 테스트 커버리지를 확보하는 것이 좋습니다. 애플리케이션이 레일즈 5.1로 업그레이드하지 않았다면 우선 업그레이드하고, 애플리케이션이 정상적으로 동작하는지 충분히 확인한 뒤에 레일즈 5.2로 올려주세요. 업그레이드 시 주의점에 대해서는 Ruby on Rails 업그레이드 가이드를 참고해주세요.
주요 변경점
Active Storage
액티브 스토리지는 Amozon S3, Google Cloud Storage, Microsoft Azure Storage 같은 클라우드 스토리지 서비스에 파일을 업로드하고 액티브 레코드 객체에 첨부하는 작업을 용이하게 합니다. 개발 및 테스트 용으로 로컬 디스크 기반 서비스가 함께 제공되고, 백업과 마이그레이션을 위해 다른 서비스로 미러링 할 수도 있습니다. 액티브 스토리지에 대한 더 자세한 내용은 Active Storage Overview 가이드를 참고하세요.
Redis 캐시 저장소
레일즈 5.2부터 Redis 캐시 저장소가 내장됩니다. 자세한 내용은 Caching with Rails: An Overview 가이드를 참고하세요.
HTTP/2 초기 힌트
레일즈 5.2부터 HTTP/2 초기 힌트를 지원합니다. 초기 힌트를 활성화하려면 서버 시작 시 --early-hints
플래그를 사용하세요.
Credentials
프로덕션 앱 보안을 위한 config/credentials.yml.enc
파일이 추가되었습니다. 서드파티 서비스의 인증 정보가 config/master.key
파일 또는 RAILS_MASTER_KEY
환경변수로 암호화되어 레파지토리에 직접 저장할 수 있습니다. 이 기능은 레일즈 5.1에서 소개했던 Rails.application.secrets
를 대체합니다. 또한, 레일즈 5.2 추가된 API를 통해 암호화된 커스텀 설정, 키, 파일 등을 쉽게 처리할 수 있습니다. 더 자세한 내용은 Securing Rails Application 가이드를 참고하세요.
Content Security Policy
레일즈 5.2는 Content Security Policy 설정을 위한 새로운 DSL이 추가되었습니다. 전역 기본 정책을 설정하고 리소스 별로 정책을 오버라이드해서 사용할 수 있으며 람다 문법을 이용해서 계정 별 서브도메인 같은 요청 별 값을 헤더에 넣을 수도 있습니다. 더 자세한 내용은 Securing Rails Application 가이드를 참고하세요.
Railties
자세한 변경사항은 변경로그를 참고하세요.
Deprecations
제너레이터와 템플릿의
capify!
메서드가 Deprecated 되었습니다. (Pull Request)rails dbconsole
,rails console
커맨드에 환경변수 이름을 매개변수로 전달하는 기능이 Deprecated 되었습니다.-e
옵션을 사용하세요. (Commit)레일즈 서버를 실행하기 위해
Rails::Application
의 서브클래스를 사용하는 것이 Deprecated 되었습니다. (Pull Request)레일즈 플러그인 템플릿의
after_bundle
콜백이 Deprecated 되었습니다. (Pull Request)
주요 변경점
config/database.yml
파일에 모든 환경에서 로드되는shared
섹션이 추가되었습니다. (Pull Request)플러그인 제너레이터에
railtie.rb
파일이 추가되었습니다. (Pull Request)tmp:clear
작업 시 스크린샷 파일들이 제거됩니다. (Pull Request)bin/rails app:update
실행 시 사용하지 않는 컴포넌트가 생략됩니다. 초기 앱 생성 시 액션 케이블, 액티브 레코드 등을 생략했다면 업데이트 작업에서도 생략됩니다. (Pull Request)3-레벨 데이터베이스 구성 사용 시
rails dbconsole
커맨드에 커스텀 연결 이름을 전달 할 수 있습니다. 예시:bin/rails dbconsole -c replica
. (Commit)bootsnap
잼이Gemfile
파일에 추가되었습니다. (Pull Request)새 레일즈 앱을 생성할 때 현재 루비 버전을
ruby x.x.x
디렉티브로Gemfile
에 추가하고.ruby-version
파일을 생성합니다. (Pull Request)플러그인 제너레이터에
--skip-action-cable
옵션이 추가되었습니다. (Pull Request)플러그인 제너레이터에서
git_source
디렉티브가Gemfile
에 추가되었습니다. (Pull Request)bin/rails
실행 시 사용하지 않는 컴포넌트가 생략됩니다. (Commit)제너레이터 액션의 들여쓰기 동작이 최적화되었습니다. (Pull Request)
라우트 생성 시 네임스페이스 들여쓰기 동작이 최적화되었습니다. (Pull Request)
플러그인 제너레이터에
--skip-yarn
옵션이 추가되었습니다. (Pull Request)제너레이터의
gem
메서드에 여러 버전 매개변수가 지원됩니다. (Pull Request)개발과 테스트 환경에서
secret_key_base
값이 앱 이름으로부터 자동으로 파생됩니다. (Pull Request)mini_magick
잼이Gemfile
파일에 주석으로 추가되었습니다. (Pull Request)rails new
와rails plugin new
에 액티브 스토리지 기능이 기본적으로 추가됩니다.--skip-active-storage
옵션으로 생략할 수 있고,--skip-active-record
옵션이 사용되면 자동적으로 함께 생략됩니다. (Pull Request)
Action Cable
자세한 변경사항은 변경로그를 참고하세요.
제거된 것
이벤트 레디스 어댑터가 제거되었습니다. (Commit)
주요 변경점
cable.yml
파일에host
,port
,db
,password
옵션이 지원됩니다. (Pull Request)PostgreSQL 어댑터 사용 시 긴 스트림 식별자를 해시해서 사용합니다. (Pull Request)
Action Pack
자세한 변경사항은 변경로그를 참고하세요.
제거된 것
ActiveController::ParamsParser::ParseError
가 제거되었습니다. (Commit)
Deprecations
ActionDispatch::TestReponse
에서#success?
,#missing?
,#error?
가 Deprecated 되었습니다. (Pull Request)
주요 변경점
프래그먼트 캐시에 재활용 가능한 캐시 키가 제공됩니다. (Pull Request)
키 변경을 쉽게 디버그하기 위해 프래그먼트에 대한 캐시 키 포맷이 변경되었습니다. (Pull Request)
쿠키 암호화를 AEAD 변경하고, 세션에 GCM을 사용합니다. (Pull Request)
폼 위변조 방지를 기본으로 적용합니다. (Pull Request)
서버 측에서 인증/암호화된 쿠키의 만료기간을 강제합니다. (Pull Request)
쿠키의
:expires
옵션이ActiveSupport::Duration
객체를 지원합니다. (Pull Request)Capybara에 등록된
:puma
서버 설정을 사용합니다. (Pull Request)쿠키 미들웨어에 키 로테이션 기능을 추가하고 단순화시켰습니다. (Pull Request)
HTTP/2 초기 힌트 기능을 활성화 할 수 있습니다. (Pull Request)
시스템 테스트에서 헤드리스 크롬을 사용할 수 있습니다. (Pull Request)
redirect_back
메서드에:allow_other_host
옵션이 추가되었습니다. (Pull Request)assert_recognizes
메서드가 마운트된 엔진을 통과하도록 했습니다. (Pull Request)Content-Security-Policy 헤더를 설정하기 위한 DSL이 추가되었습니다. (Pull Request)
모던 브라우저에서 지원되는 유명한 오디오/비디오/폰트의 MIME 타입들이 등록되었습니다. (Pull Request)
기본 시스템 테스트 스크린샷 출력을
inline
에서simple
로 변경하였습니다. (Commit)시스템 테스트에서 헤드리스 파이어폭스를 사용할 수 있습니다. (Pull Request)
보안을 위해
X-Download-Options
,X-Permitted-Cross-Domain-Policies
헤더를 기본 헤더 집합에 추가하였습니다. (Commit)시스템 테스트에서 사용자가 다른 서버를 직접 지정하지 않은 경우에만 Puma를 기본 서버로 사용하도록 변경했습니다. (Pull Request)
Referrer-Policy
헤더를 기본 헤더 집합에 추가하였습니다. (Commit)ActionController::Parameters#each
동작이Hash#each
동작과 일치하도록 수정했습니다. (Pull Request)Rails UJS에 자동 암호화 토큰(Nonce) 생성 기능이 추가되었습니다. (Commit)
https://hstspreload.org/ 요구사항을 충족하기 위해 기본 HSTS max-age 값을 31536000초(1년) 으로 수정했습니다. (Commit)
cookies
,session
객체에 각각to_hash
메서드의 별칭인to_h
메서드를 추가했습니다. (Commit)
Action View
자세한 변경사항은 변경로그를 참고하세요.
제거된 것
Erubis ERB 처리기가 제거되었습니다. (Commit)
Deprecations
image_tag
뷰 헬퍼가 자동으로 생성하는 이미지의 대체 텍스트와 여기에 사용되는image_alt
뷰 헬퍼가 Deprecated 되었습니다. (Pull Request)
주요 변경점
JSON 피드를 지원하기 위해
auto_discovery_link_tag
뷰 헬퍼에:json
타입이 추가되었습니다. (Pull Request)image_tag
뷰 헬퍼에srcset
옵션이 추가되었습니다. (Pull Request)field_error_proc
가optgroup
,select
태그를 둘 다 감싸는 문제를 수정했습니다. (Pull Request)form_with
뷰 헬퍼가 기본적으로 ID를 생성하도록 변경했습니다. (Commit)preload_link_tag
뷰 헬퍼가 추가되었습니다. (Pull Request)option_groups_from_collection_for_select
헬퍼에 호출가능한 객체를 사용할 수 있도록 변경했습니다. (Pull Request)
Action Mailer
자세한 변경사항은 변경로그를 참고하세요.
주요 변경점
액션 메일러 클래스에서 직접 딜리버리 잡을 구성할 수 있습니다. (Pull Request)
assert_enqueued_email_with
테스트 헬퍼가 추가되었습니다. (Pull Request)
Active Record
자세한 변경사항은 변경로그를 참고하세요.
제거된 것
#migration_keys
메서드가 제거되었습니다. (Pull Request)액티브 레코드 객체를 형변환 할 때
quoted_id
를 더 이상 지원하지 않습니다. (Commit)index_name_exists?
메서드에default
매개변수가 제거되었습니다. (Commit)관계 정의 시
:class_name
속성에 클래스를 전달할 수 없도록 변경되었습니다. (Commit)initialize_schema_migrations_table
,initialize_internal_metadata_table
메서드가 제거되었습니다. (Commit)supports_migrations?
메서드가 제거되었습니다. (Commit)supports_primary_key?
메서드가 제거되었습니다. (Commit)ActiveRecord::Migrator.schema_migrations_tabile_name
메서드가 제거되었습니다. (Commit)#indexes
메서드에서 Deprecated 되었던 매개변수들이 제거되었습니다. (Commit)#verify!
메서드에서 Deprecated 되었던 매개변수들이 제거되었습니다. (Commit).error_on_ignored_order_or_limit
설정이 제거되었습니다. (Commit)#scope_chain
메서드가 제거되었습니다. (Commit)#sanitize_conditions
메서드가 제거되었습니다. (Commit)
Deprecations
supports_statement_cache?
메서드가 Deprecated 되었습니다. (Pull Request)ActiveRecord::Calculations
객체의count
,sum
메서드에 매개변수와 블럭을 함께 전달할 수 없게 되습니다. (Pull Request)Relation
객체의arel
델리게이션이 Deprecated 되었습니다. (Pull Request)TransactionState
객체의set_state
메서드가 Deprecated 되었습니다. (Commit)expand_hash_conditions_for_aggregates
메서드가 Deprecated 되었습니다. (Commit)
주요 변경점
동적 픽스쳐 접근자를 인자없이 호출하면 빈 배열을 반환하는 대신 해당하는 타입의 모든 픽스쳐를 반환합니다. (Pull Request)
액티브 레코드의 어트리뷰트 리더를 오버라이딩 할 때 변경되는 어트리뷰트가 불일치 하는 문제를 수정했습니다. (Pull Request)
MySQL의 내림차순 인덱스가 지원됩니다. (Pull Request)
bin/rails db:forward
명령어가 올바르게 동작하도록 수정했습니다. (Commit)마이그레이션 변경 시 현재 마이그레이션이 존재하지 않으면
UnknownMigrationVersionError
에러가 발생합니다. (Commit)데이터베이스 구조 덤프 작업 시
SchemaDumper.ignore_tables
값이 적용되도록 수정했습니다. (Pull Request)ActiveSupport::Cache
의 버전이 적용된 항목들을 통해 재활용 가능한 캐시 키를 지원하는ActiveRecord::Base#cache_version
가 추가됐습니다. 이제ActiveRecord::Base#cache_key
가 타임스탬프를 사용하지 않고 더 안정적인 키를 반환합니다. (Pull Request)형변환 된 값이
nil
인 경우 파라미터가 바인딩되지 않도록 막습니다. (Pull Request)픽스쳐 삽입 시 더 나은 성능을 위해 일괄(Bulk)
INSERT
구문을 사용합니다. (Pull Request)두 중첩 조인 관계를 병합할 때 더 이상
LEFT OUTER JOIN
구문으로 변환되지 않습니다. (Pull Request)부모 트랜잭션을 롤백할 때 부모 트랜잭션의 상태를 자식 트랜잭션에도 반영하도록 수정했습니다. 이전에는 중첩 트랜잭션이나 외부 트랜잭션을 롤백해도 내부 트랜잭션의 레코드가 계속 지속적(persisted)인 것으로 인식했습니다. (Commit)
조인 스코프를 포함하는 Pre/Eager 로딩 관계를 수정했습니다. (Pull Request)
sql.active_record
알림 구독자가 발생시키는 에러가ActiveRecord::StatementInvalid
예외로 변환되지 않도록 수정했습니다. (Pull Request)find_each
,find_in_batches
,in_batches
메서드로 작업할 때 쿼리 캐싱이 생략됩니다. (Commit)SQLite3의 boolean 시리얼라이저가 1과 0을 사용하도록 변경했습니다. SQLite는 1과 0을 논리값으로 식별하는 것을 기본적으로 지원하지만, 이전의 't'와 'f'는 지원되지 않습니다. (Pull Request)
다중 매개변수로 할당된 속성을 폼에서 단일 필드 입력으로 사용할 수 있습니다. (Commit)
ApplicationRecord
가 더 이상 모델을 생성하지 않습니다. 생성하려면rails g application_record
명령어를 사용하세요. (Pull Request)Relation#or
메서드가 서로 다른references
값을 사용하는 경우를 허용합니다. (Commit)Relation#or
메서드를 사용할 때 일반적인 조건들을 추출해서 OR 조건 이전에 삽입합니다. (Pull Request)binary
픽스쳐 헬퍼 메서드가 추가되었습니다. (Pull Request)STI의 inverse 관계가 자동으로 추론됩니다. (Pull Request)
LockWaitTimeout
에러 클래스를 추가했습니다. (Pull Request)sql.active_record
인스트루먼테이션의 페이로드 이름이 더 자세한 내용을 나타내도록 수정했습니다. (Pull Request)데이터베이스의 인덱스를 삭제할 때 전달된 알고리즘을 사용합니다. (Pull Request)
Relation#where
메서드에Set
을 전달하는 것이 이제 배열을 전달하는 것 과 동일하게 동작합니다. (Commit)PostgreSQL
tsrange
형식이 이제 1초 미만의 정밀도를 유지합니다. (Pull Request)Dirty 레코드에서
lock!
메서드를 호출하면 에러를 발생시킵니다. (Commit)SQLite 어댑터를 사용할 때 인덱스의 열 순서가
db/schema.rb
파일에 기록되지 않는 버그를 수정했습니다. (Pull Request)bin/rails db:migrate
명령어에VERSION
값을 지정합니다.VERSION
값이 비어있으면 버전을 지정하지 않은 것처럼 동작합니다.VERSION
값에는 마이그레이션 버전 넘버나 마이그레이션 파일명을 사용할 수 있습니다. 값의 형식이 올바르지 않거나 해당하는 마이그레이션이 존재하지 않는 경우 에러가 발생합니다.StatementTimeout
에러 클래스를 추가했습니다. (Pull Request)update_all
메서드가 이제Type#serialize
메서드에 값들을 전달하기 전에Type#cast
메서드에 먼저 전달합니다. 따라서update_all(foo: 'true')
처럼 사용할 때 올바르게 boolean 타입으로 처리됩니다. (Commit)데이터베이스 마이그레이션에서 업그레이드에만 관련된 코드를 위해
#up_only
메서드를 추가했습니다. (Pull Request)Add new error class
QueryCanceled
which will be raised when canceling statement due to user request. (Pull Request)Don't allow scopes to be defined which conflict with instance methods on
Relation
. (Pull Request)Add support for PostgreSQL operator classes to
add_index
. (Pull Request)Log database query callers. (Pull Request, Pull Request, Pull Request)
Undefine attribute methods on descendants when resetting column information. (Pull Request)
Using subselect for
delete_all
withlimit
oroffset
. (Commit)Fixed inconsistency with
first(n)
when used withlimit()
. Thefirst(n)
finder now respects thelimit()
, making it consistent withrelation.to_a.first(n)
, and also with the behavior oflast(n)
. (Pull Request)Fix nested
has_many :through
associations on unpersisted parent instances. (Commit)Take into account association conditions when deleting through records. (Commit)
Don't allow destroyed object mutation after
save
orsave!
is called. (Commit)Fix relation merger issue with
left_outer_joins
. (Pull Request)Support for PostgreSQL foreign tables. (Pull Request)
Clear the transaction state when an Active Record object is duped. (Pull Request)
Fix not expanded problem when passing an Array object as argument to the where method using
composed_of
column. (Pull Request)Make
reflection.klass
raise ifpolymorphic?
not to be misused. (Commit)Fix
#columns_for_distinct
of MySQL and PostgreSQL to makeActiveRecord::FinderMethods#limited_ids_for
use correct primary key values even ifORDER BY
columns include other table's primary key. (Commit)Fix
dependent: :destroy
issue for has_one/belongs_to relationship where the parent class was getting deleted when the child was not. (Commit)
Active Model
자세한 변경사항은 변경로그를 참고하세요.
주요 변경점
Fix methods
#keys
,#values
inActiveModel::Errors
. Change#keys
to only return the keys that don't have empty messages. Change#values
to only return the not empty values. (Pull Request)Add method
#merge!
forActiveModel::Errors
. (Pull Request)Allow passing a Proc or Symbol to length validator options. (Pull Request)
Execute
ConfirmationValidator
validation when_confirmation
's value isfalse
. (Pull Request)Models using the attributes API with a proc default can now be marshalled. (Commit)
Do not lose all multiple
:includes
with options in serialization. (Commit)
Active Support
자세한 변경사항은 변경로그를 참고하세요.
제거된 것
콜백에서
:if
,:unless
문자열 필터 옵션이 제거되었습니다. (Commit)halt_callback_chains_on_return_false
옵션이 제거되었습니다. (Commit)
Deprecations
Module#reachable?
메서드가 Deprecated 되었습니다. (Pull Request)secrets.secret_token
가 Deprecated 되었습니다. (Commit)
주요 변경점
Add
fetch_values
forHashWithIndifferentAccess
. (Pull Request)Add support for
:offset
toTime#change
. (Commit)Add support for
:offset
and:zone
toActiveSupport::TimeWithZone#change
. (Commit)Pass gem name and deprecation horizon to deprecation notifications. (Pull Request)
Add support for versioned cache entries. This enables the cache stores to recycle cache keys, greatly saving on storage in cases with frequent churn. Works together with the separation of
#cache_key
and#cache_version
in Active Record and its use in Action Pack's fragment caching. (Pull Request)Add
ActiveSupport::CurrentAttributes
to provide a thread-isolated attributes singleton. Primary use case is keeping all the per-request attributes easily available to the whole system. (Pull Request)#singularize
and#pluralize
now respect uncountables for the specified locale. (Commit)Add default option to
class_attribute
. (Pull Request)Add
Date#prev_occurring
andDate#next_occurring
to return specified next/previous occurring day of week. (Pull Request)Add default option to module and class attribute accessors. (Pull Request)
Cache:
write_multi
. (Pull Request)Default
ActiveSupport::MessageEncryptor
to use AES 256 GCM encryption. (Pull Request)Add
freeze_time
helper which freezes time toTime.now
in tests. (Pull Request)Make the order of
Hash#reverse_merge!
consistent withHashWithIndifferentAccess
. (Pull Request)Add purpose and expiry support to
ActiveSupport::MessageVerifier
andActiveSupport::MessageEncryptor
. (Pull Request)Update
String#camelize
to provide feedback when wrong option is passed. (Pull Request)Module#delegate_missing_to
now raisesDelegationError
if target is nil, similar toModule#delegate
. (Pull Request)Add
ActiveSupport::EncryptedFile
andActiveSupport::EncryptedConfiguration
. (Pull Request)Add
config/credentials.yml.enc
to store production app secrets. (Pull Request)Add key rotation support to
MessageEncryptor
andMessageVerifier
. (Pull Request)Return an instance of
HashWithIndifferentAccess
fromHashWithIndifferentAccess#transform_keys
. (Pull Request)Hash#slice
now falls back to Ruby 2.5+'s built-in definition if defined. (Commit)IO#to_json
now returns theto_s
representation, rather than attempting to convert to an array. This fixes a bug whereIO#to_json
would raise anIOError
when called on an unreadable object. (Pull Request)Add same method signature for
Time#prev_day
andTime#next_day
in accordance withDate#prev_day
,Date#next_day
. Allows pass argument forTime#prev_day
andTime#next_day
. (Commit)Add same method signature for
Time#prev_month
andTime#next_month
in accordance withDate#prev_month
,Date#next_month
. Allows pass argument forTime#prev_month
andTime#next_month
. (Commit)Add same method signature for
Time#prev_year
andTime#next_year
in accordance withDate#prev_year
,Date#next_year
. Allows pass argument forTime#prev_year
andTime#next_year
. (Commit)Fix acronym support in
humanize
. (Commit)Allow
Range#include?
on TWZ ranges. (Pull Request)Cache: Enable compression by default for values > 1kB. (Pull Request)
Redis cache store. (Pull Request, Pull Request)
Handle
TZInfo::AmbiguousTime
errors. (Pull Request)MemCacheStore: Support expiring counters. (Commit)
Make
ActiveSupport::TimeZone.all
return only time zones that are inActiveSupport::TimeZone::MAPPING
. (Pull Request)Changed default behaviour of
ActiveSupport::SecurityUtils.secure_compare
, to make it not leak length information even for variable length string. Renamed oldActiveSupport::SecurityUtils.secure_compare
tofixed_length_secure_compare
, and started raisingArgumentError
in case of length mismatch of passed strings. (Pull Request)Use SHA-1 to generate non-sensitive digests, such as the ETag header. (Pull Request, Pull Request)
assert_changes
will always assert that the expression changes, regardless offrom:
andto:
argument combinations. (Pull Request)Add missing instrumentation for
read_multi
inActiveSupport::Cache::Store
. (Pull Request)Support hash as first argument in
assert_difference
. This allows to specify multiple numeric differences in the same assertion. (Pull Request)Caching: MemCache and Redis
read_multi
andfetch_multi
speedup. Read from the local in-memory cache before consulting the backend. (Commit)
Active Job
자세한 변경사항은 변경로그를 참고하세요.
주요 변경점
ActiveJob::Base.discard_on
메서드에 블럭을 전달해서 잡 취소를 커스텀으로 처리하는 것을 허용합니다. (Pull Request)
가이드 문서
자세한 변경사항은 변경로그를 참고하세요.
주요 변경점
레일즈에서 멀티스레드 코드 실행하기 가이드가 추가되었습니. (Pull Request)
액티브 스토리지 둘러보기 가이드가 추가되었습니다. (Pull Request)
크레딧
레일즈를 견고하고 안정적인 프레임워크로 만들기 위해 많은 시간을 사용해주신 많은 개발자들을 레일즈 기여자 목록에서 확인할 수 있습니다. 이 분들에게 경의를 표합니다.
Last updated