Devise - Check for Subdomain on Account Table

Hi there,

I"m building a multitenant app using apartment and devise, using
schemas and subdomain auth.

I just added subdomain , following this:

Everything is working, but this model requires that I have a subdomain
attribute on user model:

class User < ActiveRecord::Base
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, request_keys:

def self.find_for_authentication(warden_conditions)
where(:email => warden_conditions[:email], :subdomain =>

I would like to validate subdomain from an account model, which is
to my user model. (User has many accounts. Account has a subdomain

How can I achieve this?

Thanks in advance,

I forgot to add that both account and user models are on public schema,
outside of tenants.

2015-06-15 12:49 GMT-03:00 Leandro Fran├ža
[email protected]:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs