# Rails Auth With Devise

> Complete authentication setup for Ruby on Rails applications using Devise. Use when: (1) Setting up user authentication in a Rails app, (2) Adding sign in/sign up/sign out functionality, (3) Implementing email confirmation, password recovery, or account locking, (4) Configuring OmniAuth social login, (5) Adding multiple user models (User/Admin), (6) Customizing Devise views or controllers, (7) Te…

- **Type:** Skill
- **Install:** `agentstack add skill-shoebtamboli-rails-claude-skills-rails-auth-with-devise`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [Shoebtamboli](https://agentstack.voostack.com/s/shoebtamboli)
- **Installs:** 0
- **Category:** [Communication](https://agentstack.voostack.com/c/communication)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [Shoebtamboli](https://github.com/Shoebtamboli)
- **Source:** https://github.com/Shoebtamboli/rails_claude_skills/tree/main/lib/generators/claude/skills_library/rails-auth-with-devise
- **Website:** https://rubygems.org/gems/rails_claude_skills

## Install

```sh
agentstack add skill-shoebtamboli-rails-claude-skills-rails-auth-with-devise
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Rails Authentication with Devise

Devise is the most popular authentication solution for Rails, providing a complete MVC solution with 10 modular components.

## Quick Setup

```bash
# Add to Gemfile
bundle add devise

# Install Devise
rails generate devise:install

# Generate User model with authentication
rails generate devise User

# Run migrations
rails db:migrate
```

## Essential Configuration

After `devise:install`, configure in `config/environments/development.rb`:
```ruby
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
```

Set root route in `config/routes.rb`:
```ruby
root to: 'home#index'
```

## Devise Modules Reference

Enable modules in the model (e.g., `app/models/user.rb`):

| Module | Purpose | Migration Columns |
|--------|---------|-------------------|
| `:database_authenticatable` | Password hashing/storage | `email`, `encrypted_password` |
| `:registerable` | Sign up, edit, destroy account | - |
| `:recoverable` | Password reset via email | `reset_password_token`, `reset_password_sent_at` |
| `:rememberable` | "Remember me" cookie | `remember_created_at` |
| `:trackable` | Sign in stats | `sign_in_count`, `current_sign_in_at`, `last_sign_in_at`, `current_sign_in_ip`, `last_sign_in_ip` |
| `:validatable` | Email/password validations | - |
| `:confirmable` | Email confirmation | `confirmation_token`, `confirmed_at`, `confirmation_sent_at`, `unconfirmed_email` |
| `:lockable` | Lock after failed attempts | `failed_attempts`, `unlock_token`, `locked_at` |
| `:timeoutable` | Session expiration | - |
| `:omniauthable` | OAuth provider support | - |

## Controller Helpers

```ruby
# Require authentication
before_action :authenticate_user!

# Check if signed in
user_signed_in?

# Get current user
current_user

# Access session
user_session
```

For other models (e.g., Admin):
```ruby
before_action :authenticate_admin!
admin_signed_in?
current_admin
admin_session
```

## Common Tasks

### Add Custom Fields (e.g., username)

1. Generate migration:
```bash
rails g migration AddUsernameToUsers username:string:uniq
rails db:migrate
```

2. Permit in `ApplicationController`:
```ruby
class ApplicationController = 3.1.0.

## Testing

### RSpec Setup

In `spec/support/devise.rb`:
```ruby
RSpec.configure do |config|
  config.include Devise::Test::ControllerHelpers, type: :controller
  config.include Devise::Test::ControllerHelpers, type: :view
  config.include Devise::Test::IntegrationHelpers, type: :feature
  config.include Devise::Test::IntegrationHelpers, type: :request
end
```

Usage:
```ruby
sign_in user
sign_out user
```

### Minitest Setup

```ruby
class ActionDispatch::IntegrationTest
  include Devise::Test::IntegrationHelpers
end
```

## Additional Guides

- **OmniAuth setup**: See [references/omniauth.md](references/omniauth.md)
- **API authentication**: See [references/api-auth.md](references/api-auth.md)
- **Advanced patterns**: See [references/advanced.md](references/advanced.md)

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [Shoebtamboli](https://github.com/Shoebtamboli)
- **Source:** [Shoebtamboli/rails_claude_skills](https://github.com/Shoebtamboli/rails_claude_skills)
- **License:** MIT
- **Homepage:** https://rubygems.org/gems/rails_claude_skills

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-shoebtamboli-rails-claude-skills-rails-auth-with-devise
- Seller: https://agentstack.voostack.com/s/shoebtamboli
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
