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
QueryCanceledwhich 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_allwithlimitoroffset. (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 :throughassociations on unpersisted parent instances. (Commit)Take into account association conditions when deleting through records. (Commit)
Don't allow destroyed object mutation after
saveorsave!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_ofcolumn. (Pull Request)Make
reflection.klassraise ifpolymorphic?not to be misused. (Commit)Fix
#columns_for_distinctof MySQL and PostgreSQL to makeActiveRecord::FinderMethods#limited_ids_foruse correct primary key values even ifORDER BYcolumns include other table's primary key. (Commit)Fix
dependent: :destroyissue for has_one/belongs_to relationship where the parent class was getting deleted when the child was not. (Commit)
Active Model
자세한 변경사항은 변경로그를 참고하세요.
주요 변경점
Fix methods
#keys,#valuesinActiveModel::Errors. Change#keysto only return the keys that don't have empty messages. Change#valuesto 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
ConfirmationValidatorvalidation 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
:includeswith 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_valuesforHashWithIndifferentAccess. (Pull Request)Add support for
:offsettoTime#change. (Commit)Add support for
:offsetand:zonetoActiveSupport::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_keyand#cache_versionin Active Record and its use in Action Pack's fragment caching. (Pull Request)Add
ActiveSupport::CurrentAttributesto provide a thread-isolated attributes singleton. Primary use case is keeping all the per-request attributes easily available to the whole system. (Pull Request)#singularizeand#pluralizenow respect uncountables for the specified locale. (Commit)Add default option to
class_attribute. (Pull Request)Add
Date#prev_occurringandDate#next_occurringto 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::MessageEncryptorto use AES 256 GCM encryption. (Pull Request)Add
freeze_timehelper which freezes time toTime.nowin tests. (Pull Request)Make the order of
Hash#reverse_merge!consistent withHashWithIndifferentAccess. (Pull Request)Add purpose and expiry support to
ActiveSupport::MessageVerifierandActiveSupport::MessageEncryptor. (Pull Request)Update
String#camelizeto provide feedback when wrong option is passed. (Pull Request)Module#delegate_missing_tonow raisesDelegationErrorif target is nil, similar toModule#delegate. (Pull Request)Add
ActiveSupport::EncryptedFileandActiveSupport::EncryptedConfiguration. (Pull Request)Add
config/credentials.yml.encto store production app secrets. (Pull Request)Add key rotation support to
MessageEncryptorandMessageVerifier. (Pull Request)Return an instance of
HashWithIndifferentAccessfromHashWithIndifferentAccess#transform_keys. (Pull Request)Hash#slicenow falls back to Ruby 2.5+'s built-in definition if defined. (Commit)IO#to_jsonnow returns theto_srepresentation, rather than attempting to convert to an array. This fixes a bug whereIO#to_jsonwould raise anIOErrorwhen called on an unreadable object. (Pull Request)Add same method signature for
Time#prev_dayandTime#next_dayin accordance withDate#prev_day,Date#next_day. Allows pass argument forTime#prev_dayandTime#next_day. (Commit)Add same method signature for
Time#prev_monthandTime#next_monthin accordance withDate#prev_month,Date#next_month. Allows pass argument forTime#prev_monthandTime#next_month. (Commit)Add same method signature for
Time#prev_yearandTime#next_yearin accordance withDate#prev_year,Date#next_year. Allows pass argument forTime#prev_yearandTime#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::AmbiguousTimeerrors. (Pull Request)MemCacheStore: Support expiring counters. (Commit)
Make
ActiveSupport::TimeZone.allreturn 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_comparetofixed_length_secure_compare, and started raisingArgumentErrorin 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_changeswill always assert that the expression changes, regardless offrom:andto:argument combinations. (Pull Request)Add missing instrumentation for
read_multiinActiveSupport::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_multiandfetch_multispeedup. 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