Skip to content
代码片段 群组 项目
代码所有者
rails_console.md 23.49 KiB
stage: Systems
group: Distribution
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments

Rails console (FREE SELF)

At the heart of GitLab is a web application built using the Ruby on Rails framework. The Rails console. provides a way to interact with your GitLab instance from the command line, and also grants access to the amazing tools built right into Rails.

WARNING: The Rails console interacts directly with GitLab. In many cases, there are no handrails to prevent you from permanently modifying, corrupting or destroying production data. If you would like to explore the Rails console with no consequences, you are strongly advised to do so in a test environment.

The Rails console is for GitLab system administrators who are troubleshooting a problem or need to retrieve some data that can only be done through direct access of the GitLab application. Basic knowledge of Ruby is needed (try this 30-minute tutorial for a quick introduction). Rails experience is useful but not required.

Starting a Rails console session

The process for starting a Rails console session depends on the type of GitLab installation.

::Tabs

:::TabTitle Linux package (Omnibus)

sudo gitlab-rails console

:::TabTitle Docker

docker exec -it <container-id> gitlab-rails console

:::TabTitle Self-compiled (source)

sudo -u git -H bundle exec rails console -e production

:::TabTitle Helm chart (Kubernetes)

The console is in the toolbox pod. Refer to our Kubernetes cheat sheet for details.

::EndTabs

To exit the console, type: quit.

Enable Active Record logging

You can enable output of Active Record debug logging in the Rails console session by running: