# Configuration

You will need to create a [user model](https://devise-token-auth.gitbook.io/devise-token-auth/usage/model_concerns), [define routes](https://devise-token-auth.gitbook.io/devise-token-auth/usage/routes), [include concerns](https://devise-token-auth.gitbook.io/devise-token-auth/usage/controller_methods), and you may want to alter some of the [default settings](https://devise-token-auth.gitbook.io/devise-token-auth/config/initialization) for this gem. Run the following command for an easy one-step installation:

```bash
rails g devise_token_auth:install [USER_CLASS] [MOUNT_PATH]
```

or for `Mongoid`

```bash
rails g devise_token_auth:install_mongoid [USER_CLASS] [MOUNT_PATH]
```

**Example**:

```bash
rails g devise_token_auth:install User auth
```

This generator accepts the following optional arguments:

| Argument    | Default | Description                                                                                                                      |
| ----------- | ------- | -------------------------------------------------------------------------------------------------------------------------------- |
| USER\_CLASS | `User`  | The name of the class to use for user authentication.                                                                            |
| MOUNT\_PATH | `auth`  | The path at which to mount the authentication routes. [Read more](https://devise-token-auth.gitbook.io/devise-token-auth/usage). |

The following events will take place when using the install generator:

* An initializer will be created at `config/initializers/devise_token_auth.rb`. [Read more](https://devise-token-auth.gitbook.io/devise-token-auth/config/initialization).
* A model will be created in the `app/models` directory. If the model already exists, a concern (and fields for `Mongoid`) will be included at the file. [Read more](https://devise-token-auth.gitbook.io/devise-token-auth/usage/model_concerns).
* Routes will be appended to file at `config/routes.rb`. [Read more](https://devise-token-auth.gitbook.io/devise-token-auth/usage/routes).
* A concern will be included by your application controller at `app/controllers/application_controller.rb`. [Read more](https://devise-token-auth.gitbook.io/devise-token-auth/usage/controller_methods).
* For `ActiveRecord` a migration file will be created in the `db/migrate` directory. Inspect the migrations file, add additional columns if necessary, and then run the migration:

  ```bash
  rake db:migrate
  ```

You may also need to configure the following items:

* **OmniAuth providers** when using 3rd party oauth2 authentication. [Read more](https://devise-token-auth.gitbook.io/devise-token-auth/config/omniauth).
* **Cross Origin Request Settings** when using cross-domain clients. [Read more](https://devise-token-auth.gitbook.io/devise-token-auth/config/cors).
* **Email** when using email registration. [Read more](https://devise-token-auth.gitbook.io/devise-token-auth/broken-reference).
* **Multiple model support** may require additional steps. [Read more](https://devise-token-auth.gitbook.io/devise-token-auth/usage/multiple_models).
