Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8588921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:55:15+00:00 2026-06-11T22:55:15+00:00

I have two user models one is 1. User.rb (this is my own authentication

  • 0

I have two user models one is
1. User.rb (this is my own authentication system which handles users that just sign up within my site.

  1. Authenticate.rb (this is the OmniAuth authentication for users that want to signup through facebook.

Im having a hard time handling both models…..for example here is the code for my navigation

   - if fb_signed_in?
      .nav.pull-right.padding-top
        %li
        - if fb_signed_in?
          %li#fat-menu.dropdown
            %a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#"}
              %span
                Signed in as
                = fb_current_user.email              
            %ul.dropdown-menu
              %li= link_to "Profile", "#"
              %li.divider
              %li= link_to "Sign out", leave_path, method: "get"             
        - else 
          .nav.pull-right
          %span.light_color Already a Member?
          = link_to "Sign in", signin_path, class: 'light_color'
          %span.light_color or
          = link_to "Sign up", signup_path, class: 'light_color' 

    - else
      .nav.pull-right.padding-top
        %li
        - if signed_in?
          %li#fat-menu.dropdown
            %a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#"}
              %span
                Signed in as
                = current_user.email              
            %ul.dropdown-menu
              %li= link_to "Profile", "#"
              %li.divider
              %li= link_to "Sign out", signout_path, method: "get"             
        - else 
          .nav.pull-right
          %span.light_color Already a Member?
          = link_to "Sign in", signin_path, class: 'light_color'
          %span.light_color or
          = link_to "Sign up", signup_path, class: 'light_color'

So i have defined a fb_signed_in? adn a signed_in? which basically does the same thing though..also with current_user and fb_current_user but heres the code for both

current_user

    def current_user
  @current_user = @current_user ||    
       User.find_by_remember_token(cookies[:remember_token])
    end

and this is for fb_current_user

    def fb_current_user
      @fb_current_user ||= Authenticate.find(session[:user_id]) if session[:user_id]
    end

so they do do different things….but is there a way to make those two one…since it will be a lot cleaner and im trying to create a comment system that will print users name and gravatar image and im getting confused on how to write the code for that since it uses gravatar_for @user and i would also have to do gravatar_for @authenticate for fb users.

Im basically using Hartl’s authentication and trying to integrate Omniauth with it

Please let me know if the question is confusing or unclear and i will try to explain better

Thank You

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T22:55:16+00:00Added an answer on June 11, 2026 at 10:55 pm

    How about:

    def current_user
      if session[:user_id]
        @current_user ||= Authenticate.find(session[:user_id])
      else
        @current_user ||= User.find_by_remember_token(cookies[:remember_token])
      end
    end
    
    def signed_in?
      current_user.is_a?(User) || current_user.is_a?(Authenticate)
    end
    

    Although this may cause problems in other places since you don’t know what a current_user is without testing its type.

    In my projects I have just one User model which has many Authorizations, where I put the omniauth-related stuff (so current_user is always a User).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two models User and Admin(with RailsAdmin) that use Devise. I sign in
So I have two models: User and ScheduledSession The users have roles. One of
I have two models User and Category that have a HABTM association. I would
I have two models -- User and Entry -- that are related through a
I have two devise models: User and Member As such, I'm specifying authentication keys
I'm trying to get my head around this one: Say you have two models
I have two models user and biography , both of them have one to
I am developing a rails application in which I have two models User and
I have two models namely acl and user. Each have there own set of
I have two models: User (email:string) Profile (name:string) class User < ActiveRecord::Base has_one :profile

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.