Skip to content

Instantly share code, notes, and snippets.

@tiagogeraldi
Created August 8, 2018 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiagogeraldi/3f9c7b4c34a006c4437f521fb0437b3a to your computer and use it in GitHub Desktop.
Save tiagogeraldi/3f9c7b4c34a006c4437f521fb0437b3a to your computer and use it in GitHub Desktop.
Part of Apartment with no subdomain
class TenantSessionsController < ApplicationController
skip_before_action :tenant_session
#layout 'devise'
def new
# clean any logged user up
reset_session
end
def create
if Customer.find_by(name: tenant_params[:name])
session[:tenant] = tenant_params[:name]
redirect_to root_path
else
flash[:error] = 'Customer not found'
redirect_to [:new, :tenant_session]
end
end
protected
def tenant_params
params.require(:tenant).permit(:name)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment