Rails Setup

Rails Setup

  • Rails
  • Devise
  • GitHub

›Advanced Topics

General

  • Overview
  • Starting with rails?

Getting Started

  • Installation
  • Controller filters and helpers
  • Configuring Models
  • Strong Parameters
  • Configuring views
  • Configuring controllers
  • Configuring routes

Advanced Topics

  • I18n
  • Test helpers
  • OmniAuth
  • Configuring multiple models
  • ActiveJob integration
  • Password reset tokens and Rails logs
  • Other ORMs
  • Rails API mode

Guides

  • Guides list

Project

  • Extensions
  • Example Applications
  • Contributing
  • Bug reports
  • Additional information

Rails API mode

Rails 5+ has a built-in API Mode which optimizes Rails for use as an API (only). One of the side effects is that it changes the order of the middleware stack, and this can cause problems for Devise::Test::IntegrationHelpers. This problem usually surfaces as an undefined method `[]=' for nil:NilClass error when using integration test helpers, such as #sign_in. The solution is simply to reorder the middlewares by adding the following to test.rb:

Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Cookies
Rails.application.config.middleware.insert_before Warden::Manager, ActionDispatch::Session::CookieStore

For a deeper understanding of this, review this issue.

Last updated on 2019-7-7
← Other ORMsGuides list →
Rails Setup 2019