---
title: Ruby agent installation: Rails plugin
source: https://docs.newrelic.com/docs/apm/agents/ruby-agent/installation/ruby-agent-installation-rails-plugin
---

These instructions are for installing the Ruby agent as a Rails plugin. For most use cases, you should instead [install the agent gem](https://docs.newrelic.com/docs/agents/ruby-agent/installation-configuration/ruby-agent-installation#Installing_the_Gem).

## Install the New Relic Rails plugin [#Installing_the_Plugin]

> #### ⚠️ IMPORTANT
>
> We strongly recommend [installing the Ruby agent as a gem](https://docs.newrelic.com/docs/agents/ruby-agent/installation-configuration/ruby-agent-installation#Installing_the_Gem) to have better control over versions and dependencies.

To install the Rails plugin from Github, use the following commands for Rails versions 2 or higher:

```sh
script/plugin install git://github.com/newrelic/newrelic-ruby-agent.git
mv vendor/plugins/rpm vendor/plugins/newrelic-ruby-agent
```

This will export the Rails plugin into your application's `vendor/plugins` directory. If you can't install the Rails plugin directly from the git URL, you can clone the repository into the vendor/plugins directory.

## Update the configuration file [#Configuration_file]

After installing the agent, copy the `newrelic.yml` file into the `config` subdirectory of your application. You can download a fresh `newrelic.yml` that includes your license key from the **Account settings** when logged in to New Relic.

> #### ⚠️ IMPORTANT
>
> As part of the installation process, change the default [application name](https://docs.newrelic.com/docs/site/naming-your-application) to a meaningful name.

## Update the newrelic.yml file [#Updating_newrelicyml]

Whenever you update the agent, confirm that your Ruby agent configuration file (`config/newrelic.yml`) is updated:

-   Open the default `newrelic.yml` file that lives in the Ruby agent's plugin folder (`vendor/plugins/newrelic-ruby-agent/newrelic.yml`).
-   Look for new configuration options that aren't in your `config/newrelic.yml` file.

> #### 💡 TIP
>
> You can reference secrets stored in [Rails credentials](https://edgeguides.rubyonrails.org/security.html#custom-credentials) in your `newrelic.yml` file using YAML interpolation:
>
> ```yml
>   # When you have a key that exists in config/credentials.yml.enc like 'newrelic_license_key'...
>   license_key: <%= Rails.application.credentials.newrelic_license_key %>
> ```

## View logs for your APM and infrastructure data [#logs-context]

You can also bring your logs and application's data together to make troubleshooting easier and faster. With [logs in context](https://docs.newrelic.com/docs/logs/logs-context/configure-logs-context-ruby/), you can see log messages related to your errors and traces directly in your app's UI. You can also see logs in context of your [infrastructure data](https://docs.newrelic.com/docs/logs/forward-logs/forward-your-logs-using-infrastructure-agent/), such as Kubernetes clusters. No need to switch to another UI page.

## Update the Ruby agent [#Update_the_Agent]

When using Subversion with the Rails plugin, be sure to remove the old agent plugin before reinstalling.

> #### 💡 TIP
>
> Use the gem if possible.

```sh
svn rm vendor/plugins/newrelic-ruby-agent svn commit vendor/plugins -m "removing old version of newrelic"
```

Then, to install the latest Ruby agent plugin:

```sh
script/rails plugin install git://github.com/newrelic/newrelic-ruby-agent.git vendor/plugins/newrelic-ruby-agent
mv vendor/plugins/rpm vendor/plugins/newrelic-ruby-agent
svn add vendor/plugins/newrelic-ruby-agent
svn commit vendor/plugins -m "upgrading newrelic to version X.X.X"
```

## Uninstall the Rails plugin [#Uninstalling_Plugin]

To uninstall the Rails plugin:

```sh
svn rm vendor/plugins/newrelic-ruby-agent svn commit vendor/plugins
```
