Sign in through GitHub

RailsCasts Pro episodes are now free!

Learn more or hide this

ThreeWest's Profile

GitHub User: ThreeWest

Comments by

Avatar

I actually got this to work just now with Sorcery.

This is what the code has to be to work:

def current_account
current_user.account
end

helper_method :current_account

def scope_current_account
Account.current_id = current_account
yield
ensure
Account.current_id = nil
end

I believe adding the ability to change the scope for the user model was so an account admin could add new users with the correct account id. Currently this is the part that threw me with Sorcery since it doesn't allow this (at least not using this method). I could make it so when the admins create a new user, the account_id gets added via something like @user.account_id = @account.id.

Avatar

Anyone get this working with sorcery?

This isn't working for me without subdomains. It seems current_account remains on the first account created no matter what. So basically when account2 logs in, it can see all the records for account 1 and when account2 creates a record, the record gets assigned the account_id of account1.

Avatar

I have this issue as well and it's the only thing keeping me from deploying my app right now. I can do a skip_around_filter and the homepage (static pages) will work and so will the subdomain but this is not a good solution on controllers that have actions that either need to be scoped or unscoped. For example, the registrations controller needs to have the new/create actions unscoped so people can register for a new account and then have the edit/update action scoped so only the right user can update their account.

It seems like this railscast should have covered routing. I followed his railscast for subdomains but for some reason, doing a match doesn't do anything in rails 4.2. I think it's still supposed to be working but it has no affect on anything if I use constraints as I've found in the rails casts and on stackoverflow.

I guess I can do the skip filter now and try to be more specific in the registration controller.