# 数据库类

## NullDB Connection Adapter

> <https://github.com/nulldb/nulldb>

当我们在本地执行`RAILS_ENV=production rails assets:precompile`编译资源时，会提示我们production数据库不存在，通过Gem `activerecord-nulldb-adapter` 可以避免创建数据库

{% code title="Gemfile" %}

```ruby
gem 'activerecord-nulldb-adapter'
```

{% endcode %}

```bash
RAILS_ENV=production DATABASE_ADAPTER=nulldb rails assets:precompile
```

{% code title="config/database.yml" %}

```yaml
default: &default
  adapter: <%= ENV.fetch('DATABASE_ADAPTER', 'postgresql') %>
  encoding: <%= ENV.fetch('DATABASE_ENCODING', 'unicode') %>
  # For details on connection pooling, see rails configuration guide
  # http://guides.rubyonrails.org/configuring.html#database-pooling
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  host: <%= ENV['DATABASE_HOST'] %>
  username: <%= ENV['DATABASE_USERNAME'] %>
  password: <%= ENV['DATABASE_PASSWORD'] %>
  port: <%= ENV['DATABASE_PORT'] %>
  timeout: 10
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.tanmer.cn/gem/ruby-on-rails/shu-ju-ku-lei.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
