Ruby on Rails 6.1 릴리스 노트

Rails 6.1의 주요 기능:

  • 데이터베이스별 연결 전환
  • 수평 분할
  • 엄격한 로딩 연관관계
  • 위임된 유형
  • 비동기 연관관계 삭제

이 릴리스 노트에서는 주요 변경 사항만 다룹니다. 다양한 버그 수정 및 변경 사항에 대해서는 변경 로그를 참조하거나 GitHub의 Rails 주 저장소에서 커밋 목록을 확인하십시오.


Rails 6.1로 업그레이드하기

기존 애플리케이션을 업그레이드하는 경우, 업데이트를 시작하기 전에 충분한 테스트 커버리지를 확보하는 것이 좋습니다. 또한 Rails 6.0으로 먼저 업그레이드하고 애플리케이션이 여전히 예상대로 작동하는지 확인한 후에 Rails 6.1로 업데이트를 시도해야 합니다. Rails 6.0에서 Rails 6.1로 업그레이드할 때 주의해야 할 사항 목록은 Ruby on Rails 업그레이드 가이드에서 확인할 수 있습니다.

주요 기능

데이터베이스별 연결 전환

Rails 6.1에서는 데이터베이스별로 연결을 전환할 수 있는 기능을 제공합니다. Rails 6.0에서는 reading 역할로 전환하면 모든 데이터베이스 연결도 읽기 역할로 전환되었습니다. 이제 Rails 6.1에서는 구성에서 legacy_connection_handlingfalse로 설정하면 해당 추상 클래스에서 connected_to를 호출하여 단일 데이터베이스에 대한 연결을 전환할 수 있습니다.

수평 분할

Rails 6.0에서는 데이터베이스를 기능적으로 분할(다중 파티션, 다른 스키마)할 수 있는 기능을 제공했지만, 수평 분할(동일한 스키마, 다중 파티션)을 지원할 수 없었습니다. 이는 Active Record의 모델이 역할별로 클래스당 하나의 연결만 가질 수 있었기 때문입니다. 이제 이 문제가 해결되어 Rails에서 수평 분할을 사용할 수 있습니다.

엄격한 로딩 연관관계

엄격한 로딩 연관관계를 통해 모든 연관관계를 적극적으로 로드하고 N+1 문제가 발생하기 전에 이를 방지할 수 있습니다.

위임된 유형

위임된 유형은 단일 테이블 상속의 대안입니다. 이를 통해 상위 클래스가 자체 테이블로 표현되는 구체 클래스인 클래스 계층을 나타낼 수 있습니다. 각 하위 클래스에는 추가 속성을 위한 자체 테이블이 있습니다.

비동기 연관관계 삭제

비동기 연관관계 삭제를 통해 애플리케이션에서 백그라운드 작업으로 연관관계를 destroy할 수 있습니다. 이를 통해 데이터를 삭제할 때 발생할 수 있는 시간 초과 및 기타 성능 문제를 해결할 수 있습니다.

Railties

자세한 변경 사항은 변경 로그를 참조하십시오.

제거

  • rake notes 작업 제거.

  • rails dbconsole 명령의 connection 옵션 제거.

  • rails notesSOURCE_ANNOTATION_DIRECTORIES 환경 변수 지원 제거.

  • rails 서버 명령의 server 인수 제거.

  • 서버 IP를 지정하기 위해 HOST 환경 변수를 사용하는 지원 제거.

  • rake dev:cache 작업 제거.

  • rake routes 작업 제거.

  • rake initializers 작업 제거.

사용 중단

주요 변경 사항

Action Cable

자세한 변경 사항은 변경 로그를 참조하십시오.

제거

사용 중단

주요 변경 사항

Action Pack

자세한 변경 사항은 변경 로그를 참조하십시오.

제거

  • ActionDispatch::Http::ParameterFilter 제거.

  • 컨트롤러 수준에서 force_ssl 제거.

사용 중단

  • config.action_dispatch.return_only_media_type_on_content_type 사용 중단.

주요 변경 사항

  • ActionDispatch::Response#content_type이 전체 Content-Type 헤더를 반환하도록 변경.

Action View

자세한 변경 사항은 변경 로그를 참조하십시오.

제거

  • ActionView::Template::Handlers::ERBescape_whitelist 제거.

  • ActionView::Resolverfind_all_anywhere 제거.

  • ActionView::Template::HTMLformats 제거.

  • ActionView::Template::RawFileformats 제거.

  • ActionView::Template::Textformats 제거.

  • ActionView::PathSetfind_file 제거.

  • ActionView::LookupContextrendered_format 제거.

  • ActionView::ViewPathsfind_file 제거.

  • ActionView::Base#initialize의 첫 번째 인수로 ActionView::LookupContext가 아닌 객체를 전달하는 지원 제거.

  • ActionView::Base#initializeformat 인수 제거.

  • ActionView::Template#refresh 제거.

  • ActionView::Template#original_encoding 제거.

  • ActionView::Template#variants 제거.

  • ActionView::Template#formats 제거.

  • ActionView::Template#virtual_path= 제거.

  • ActionView::Template#updated_at 제거.

  • ActionView::Template#initialize에 필요한 updated_at 인수 제거.

  • ActionView::Template.finalize_compiled_template_methods 제거.

  • config.action_view.finalize_compiled_template_methods 제거

  • ActionView::ViewPaths#with_fallback에 블록을 전달하는 지원 제거.

  • render template:에 절대 경로를 전달하는 지원 제거.

  • render file:에 상대 경로를 전달하는 지원 제거.

  • 두 개의 인수를 받지 않는 템플릿 핸들러 지원 제거.

  • ActionView::Template::PathResolverpattern 인수 제거.

  • 객체의 private 메서드를 일부 뷰 헬퍼에서 호출하는 지원 제거.

사용 중단

주요 변경 사항

  • ActionView::Base 하위 클래스가 #compiled_method_container를 구현하도록 요구.

  • ActionView::Template#initializelocals 인수를 필수로 지정.

  • javascript_include_tagstylesheet_link_tag 자산 헬퍼는 현대 브라우저에 자산 프리로딩에 대한 힌트를 제공하는 Link 헤더를 생성합니다. 이는 config.action_view.preload_links_headerfalse로 설정하여 비활성화할 수 있습니다.

Action Mailer

자세한 변경 사항은 변경 로그를 참조하십시오.

제거

  • Action Mailbox를 사용하도록 ActionMailer::Base.receive를 제거.

사용 중단

주요 변경 사항

Active Record

자세한 변경 사항은 변경 로그를 참조하십시오.

제거

  • ActiveRecord::ConnectionAdapters::DatabaseLimits에서 다음 메서드 제거:

    column_name_length table_name_length columns_per_table indexes_per_table columns_per_multicolumn_index sql_query_length joins_per_query

  • ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_multi_insert? 제거.

  • ActiveRecord::ConnectionAdapters::AbstractAdapter#supports_foreign_keys_in_create? 제거.

  • ActiveRecord::ConnectionAdapters::PostgreSQLAdapter#supports_ranges? 제거.

  • ActiveRecord::Base#update_attributesActiveRecord::Base#update_attributes! 제거.

  • ActiveRecord::ConnectionAdapter::SchemaStatements#assume_migrated_upto_versionmigrations_path 인수 제거.

  • config.active_record.sqlite3.represent_boolean_as_integer 제거.

  • ActiveRecord::DatabaseConfigurations에서 다음 메서드 제거:

    fetch each first values []=

  • ActiveRecord::Result#to_hash 메서드 제거.

  • ActiveRecord::Relation 메서드에서 안전하지 않은 원시 SQL 사용 지원 제거.

사용 중단

  • ActiveRecord::Base.allow_unsafe_raw_sql 사용 중단.

  • connected_todatabase 키워드 인수 사용 중단.

  • legacy_connection_handlingfalse로 설정된 경우 connection_handlers 사용 중단.

주요 변경 사항

  • MySQL: 고유성 유효성 검사기가 기본 데이터베이스 콜레이션을 존중하며, 더 이상 기본적으로 대소문자 구분 비교를 강제하지 않습니다.

  • relation.create가 초기화 블록과 콜백에서 클래스 수준 쿼리 메서드로 범위를 더 이상 누출하지 않습니다.

    이전:

    User.where(name: "John").create do |john|
      User.find_by(name: "David") # => nil
    end
    

    이후:

    User.where(name: "John").create do |john|
      User.find_by(name: "David") # => #<User name: "David", ...>
    end
    
  • 명명된 범위 체인이 더 이상 클래스 수준 쿼리 메서드로 범위를 누출하지 않습니다.

    class User < ActiveRecord::Base
      scope :david, -> { User.where(name: "David") }
    end
    

    이전:

    User.where(name: "John").david
    # SELECT * FROM users WHERE name = 'John' AND name = 'David'
    

    이후:

    User.where(name: "John").david
    # SELECT * FROM users WHERE name = 'David'
    
  • where.not이 이제 NOR 대신 NAND 술어를 생성합니다.

    이전:

    User.where.not(name: "Jon", role: "admin")
    # SELECT * FROM users WHERE name != 'Jon' AND role != 'admin'
    

    이후:

    User.where.not(name: "Jon", role: "admin")
    # SELECT * FROM users WHERE NOT (name = 'Jon' AND role = 'admin')
    
  • 새로운 데이터베이스별 연결 처리를 사용하려면 애플리케이션에서 legacy_connection_handlingfalse로 변경하고 deprecated 접근자를 제거해야 합니다. connects_toconnected_to의 공개 메서드는 변경할 필요가 없습니다.

Active Storage

자세한 변경 사항은 변경 로그를 참조하십시오.

제거

  • ActiveStorage::Transformers::ImageProcessing:combine_options 작업을 전달하는 지원 제거.

  • ActiveStorage::Transformers::MiniMagickTransformer 제거.

  • config.active_storage.queue 제거.

  • ActiveStorage::Downloading 제거.

사용 중단계속해서 번역한 내용은 다음과 같습니다:

사용 중단

  • Blob.create_after_uploadBlob.create_and_upload로 대체하는 것이 좋습니다. (Pull Request)

주요 변경 사항

  • Blob.create_and_upload를 추가하여 새 blob을 생성하고 제공된 io를 서비스에 업로드할 수 있습니다. (Pull Request)
  • ActiveStorage::Blob#service_name 열이 추가되었습니다. 업그레이드 후 마이그레이션을 실행해야 합니다. bin/rails app:update를 실행하여 해당 마이그레이션을 생성하십시오.

Active Model

자세한 변경 사항은 변경 로그를 참조하십시오.

제거

사용 중단

주요 변경 사항

  • Active Model의 오류가 이제 애플리케이션이 오류를 더 쉽게 처리하고 상호 작용할 수 있는 인터페이스를 가진 객체입니다. 이 기능에는 쿼리 인터페이스, 더 정확한 테스트, 오류 세부 정보에 대한 액세스가 포함됩니다.

Active Support

자세한 변경 사항은 변경 로그를 참조하십시오.

제거

  • config.i18n.fallbacks가 비어 있을 때 I18n.default_locale로 대체하는 것 제거.

  • LoggerSilence 상수 제거.

  • ActiveSupport::LoggerThreadSafeLevel#after_initialize 제거.

  • Module#parent_name, Module#parentModule#parents 제거.

  • active_support/core_ext/module/reachable 파일 제거.

  • active_support/core_ext/numeric/inquiry 파일 제거.

  • active_support/core_ext/array/prepend_and_append 파일 제거.

  • active_support/core_ext/hash/compact 파일 제거.

  • active_support/core_ext/hash/transform_values 파일 제거.

  • active_support/core_ext/range/include_range 파일 제거.

  • ActiveSupport::Multibyte::Chars#consumes?ActiveSupport::Multibyte::Chars#normalize 제거.

  • ActiveSupport::Multibyte::Unicode.pack_graphemes, ActiveSupport::Multibyte::Unicode.unpack_graphemes, ActiveSupport::Multibyte::Unicode.normalize, ActiveSupport::Multibyte::Unicode.downcase, ActiveSupport::Multibyte::Unicode.upcaseActiveSupport::Multibyte::Unicode.swapcase 제거.

  • ActiveSupport::Notifications::Instrumenter#end= 제거.

사용 중단

  • ActiveSupport::Multibyte::Unicode.default_normalization_form 사용 중단.

주요 변경 사항

Active Job

자세한 변경 사항은 변경 로그를 참조하십시오.

제거

사용 중단

  • config.active_job.return_false_on_aborted_enqueue 사용 중단.

주요 변경 사항

  • 작업 enqueue가 중단되면 false를 반환합니다.

Action Text

자세한 변경 사항은 변경 로그를 참조하십시오.

제거

사용 중단

주요 변경 사항

  • rich text 콘텐츠 존재 여부를 확인하는 메서드를 추가했습니다. rich text 속성 이름 뒤에 ?를 추가하면 됩니다. (Pull Request)

  • trix 편집기를 찾아 주어진 HTML 콘텐츠로 채우는 fill_in_rich_text_area 시스템 테스트 케이스 헬퍼를 추가했습니다. (Pull Request)

  • 데이터베이스 fixture에서 <action-text-attachment> 요소를 생성하는 ActionText::FixtureSet.attachment를 추가했습니다. (Pull Request)

Action Mailbox

자세한 변경 사항은 변경 로그를 참조하십시오.

제거

사용 중단

  • Rails.application.credentials.action_mailbox.api_keyMAILGUN_INGRESS_API_KEYRails.application.credentials.action_mailbox.signing_keyMAILGUN_INGRESS_SIGNING_KEY로 대체하는 것이 좋습니다.

주요 변경 사항

Ruby on Rails 가이드

자세한 변경 사항은 변경 로그를 참조하십시오.

주요 변경 사항

크레딧

Rails에 많은 시간을 투자하여 안정적이고 견고한 프레임워크로 만든 많은 기여자의 전체 목록을 참조하십시오. 모든 분들께 박수를 보냅니다.