<a id="how-to-access-the-rails-console"></a>

# How to access the Rails console

Ideally, the Discourse charm should be handled by interacting with Juju, and everything that can be done with the console should
be doable with Juju actions. In case there is something that needs to be done with the console anyway, the console can be accessed.

## Prerequisites

Have a Discourse deployment active.

## Access the console

First of all, switch into the Juju Discourse model if necessary:

```default
juju switch discourse-model
```

Then SSH into the Discourse unit:

```default
juju ssh --container discourse discourse-k8s/leader bash   
```

Now access the console using Pebble:

```default
pebble exec --user=_daemon_ --context=discourse -w=/srv/discourse/app -ti -- /srv/discourse/app/bin/bundle exec rails console
```

If the output of the last command contains something similar to this:

```text
Loading production environment (Rails 7.0.5.1)
irb(main):001:0>
```

Congratulations, you have accessed the rails console.
