ruby-on-railsruby-on-rails-5rails-adminrails-administrate

How to use subdomain with Rails_admin on rails


I have rails admin with my application and when i try to access rails_admin by entering localhost:3000/admin it generates the followibg routing error

Routing Error No route matches [GET] "/users/sign_in"

my device routes on routes.rb is

require 'subdomain_constraint'

require 'domain_constraint'

Rails.application.routes.draw do

mount RailsAdmin::Engine => '/admin', as: 'rails_admin'

constraints SubdomainConstraint do

use_doorkeeper

root 'org_public/home#index'

devise_for :users, controllers: {
  sessions: 'users/sessions',
  passwords: 'users/passwords',
  registrations: 'users/registrations'
}

Solution

  • class SubdomainConstraint
     def self.matches?(request)
    request.subdomain.present? || %w[public www].exclude?(request.subdomain)
    end
    end
    

    This code fixed my error i just put this code in subdomain_constraint.rb file