The way you set it up, it seems that you are able to log in as both a user and an affiliate at the same time. That means, that at a given moment there could be a current_user and a current_affiliate. If you want it to be current_user all the time, you can override the Devise helpers.
But you have to make sure that a there can only be a user OR an affiliate logged in, through one session. Else Devise has no way of knowing which object to return for current_user.
Up vote 0 down vote favorite share g+ share fb share tw.
I'm using devise to help with my authentication and for various reasons I have a couple subclasses of the User model that helps separate the concerns for registration and some other business logic. The subclasses of User are Affiliate and Admin (and I might have more in the future), all of which store all of the data in the User table (not separate tables). All users can log in via the default users resource (/users/sign_in).
However, this is where I'm having an issue. If the user signs in via the /users/sign_in resource I can access the user_signed_in? And current_user helper and then access any other Active Record associations.
This is what I want! Woo hoo! This works great.
However, the same is not true of a user who signs up as an Affiliate. Since devise automatically logs the user in (which I DO want) I expect that user_signed_in? To equal true and current_user to be the user that just signed in.
This is not the case when a user signs up via the /affiliate/sign_up resource. On the Affiliate model (remember, it subclasses user like such class Affiliate Is false. But, the helpers current_affiliate is a hydrated object and affiliate_signed_in?
Is true. What I want to do is be able to access ONE type of helper - the user_signed_in? Helper and the current_user helper not the child affiliate_signed_in?
And current_affiliate. I'd like to access: current_user and user_signed_in only. Seeing that Affiliate subclasses User, why doesn't user_signed_in?
And current_user returned the current user (aka: the Affiliate)? Why do the current_affiliate and affiliate_signed_in? Helpers work, but not the user-esque ones not?
Is there a way to make the framework always use current_user and user_signed_in? Helpers since everything is subclassing the User model? Ruby-on-rails ruby-on-rails-3 ruby-on-rails-3.1 devise link|improve this question asked Apr 4 at 17:13Donn Felker1,086615 86% accept rate.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.