Ruby Active Record는 Ruby on Rails와 함께 제공되는 객체 관계형 매핑(ORM) 라이브러리입니다.
Active Record는 기본 데이터베이스를 추상화하며 스키마 변경사항 자동 생성 및 스키마 버전 기록 관리와 같은 기능을 포함합니다.
Active Record용 Spanner 지원을 사용 설정하면 Active Record 사용자가 Spanner 데이터베이스를 사용할 수 있습니다. 이 지원을 통해 Ruby 애플리케이션은 ORM을 통해 규모에 맞게 Spanner의 고가용성 및 외적 일관성을 활용할 수 있습니다.
Active Record용 Spanner 지원 인증에 따라 서비스 계정 JSON 사용자 인증 정보 파일 위치를 GOOGLE_APPLICATION_CREDENTIALS 환경 변수에 제공해야 합니다.
그렇지 않으면 Active Record용 Spanner 지원에서 Google Cloud SDK gcloud 애플리케이션에 설정된 기본 사용자 인증 정보를 사용할 수도 있습니다.
Active Record용 Spanner 지원 사용
사용 가능한 기능, Active Record용 Spanner 지원 제한사항에 대한 자세한 내용과 사용 방법 및 코드 샘플에 대한 권장사항은 GitHub의 참고 문서를 확인하세요.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-03(UTC)"],[],[],null,["# Using Active Record with Spanner\n\nRuby [Active Record](https://guides.rubyonrails.org/active_record_basics.html) is an Object-Relational\nMapping (ORM) library bundled with [Ruby on Rails](https://rubyonrails.org/).\nActive Record provides an abstraction over the underlying database and\nincludes capabilities such as automatically generating schema changes and\nmanaging schema version history.\n\nThe [Spanner support for Active Record](https://github.com/googleapis/ruby-spanner-activerecord)\nenables [Active Record](https://guides.rubyonrails.org/active_record_basics.html) users to use Spanner\ndatabases. With this support, Ruby applications can take advantage of\nSpanner's high availability and external consistency at scale through\nan ORM.\n\n\n| **PostgreSQL interface note:** The [PostgreSQL interface for Spanner](/spanner/docs/postgresql-interface) doesn't support Active Record.\n\n\u003cbr /\u003e\n\nSetting up the Spanner support for Active Record\n------------------------------------------------\n\nTo setup the Spanner support for Active Record in your application, edit the\n`Gemfile` of your Rails application and add the\n[activerecord-spanner-adapter](https://rubygems.org/gems/activerecord-spanner-adapter)\ngem. \n\n gem 'activerecord-spanner-adapter'\n\nNext, run bundle to install the gem. \n\n bundle install\n\nAs authentication for the Spanner support for Active Record, the\n[service account JSON credentials](/docs/authentication/getting-started) file location should be\nprovided in the `GOOGLE_APPLICATION_CREDENTIALS` environment variable.\nOtherwise, the Spanner support for Active Record can also use the default credentials\nset in the Google Cloud SDK `gcloud` application.\n\nUsing the Spanner support for Active Record\n-------------------------------------------\n\nFor more information about the available features, limitations of the\nSpanner support for Active Record, recommendations on how to use it, and for code\nsamples, please consult the\n[reference documentation](https://github.com/googleapis/ruby-spanner-activerecord#readme)\non GitHub.\n\nWhat's next\n-----------\n\n- Checkout the [code examples](https://github.com/googleapis/ruby-spanner-activerecord#examples) on how to use the Spanner support for Active Record.\n- View the repository for the Spanner support for Active Record on [GitHub](https://github.com/googleapis/ruby-spanner-activerecord).\n- File a [GitHub issue](https://github.com/googleapis/ruby-spanner-activerecord/issues) to report a bug or ask a question about the Spanner support for Active Record.\n- Learn more about [Active Record](https://guides.rubyonrails.org/active_record_basics.html).\n- Learn more about [Ruby Gems](https://rubygems.org/).\n- Learn about authorization and authentication credentials in [Getting started with authentication](/docs/authentication/getting-started)."]]