In my model email token i have

```
def self.token_valid(token, type)
   return unless token.present?
   token = EmailToken.where("token = ? and verification_type = ? and confirmed = 'false' and created_at <= ?", token, type, EmailToken.expires).includes(:user).first
   user = token.user
 end

```

And I call this method from my controller

```
def confirm_password_reset
    @user = EmailToken.token_valid(params[:pass_reset],"password")
    render 'reset_password' if @user
end

```

The conditions are valid because I've tested it without trying to associate it with the user and it works. What I'm trying to do is to get `token_valid` method to confirm the token and return both the token and it's associated user.
The `belongs_to` and `has_many` del have also been defined.  

`Current error : undefined method user for nil:NilClass`  

Thanks.