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 6565551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:06:27+00:00 2026-05-25T14:06:27+00:00

I am working on a web app with a public site and an admin

  • 0

I am working on a web app with a public site and an admin site. They both share a table : Users, the model of which is in the public site. How can I share this table with the admin app?

  • 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-05-25T14:06:28+00:00Added an answer on May 25, 2026 at 2:06 pm

    If I were you, I wouldn’t separate the public and the admin functionality. Instead build both of them as part of the same site, just namespace the admin routes and control who gets access to admin functionality via something like CanCan (although you can hand-roll a solution quite easily as well).

    If you can’t do that then, as one of the other answers pointed out, you can create a duplicate User model in your admin site and override the connection for that model to point to your public database. So in your config/database.yml, you need to add a database configuration for you public database:

    public_production:
      adapter: postgresql
      database: public_production
      username: blah
      password:
      host: localhost
    
    #this is your existing production db
    production:
      adapter: postgresql
      database: admin_production
      username: blah
      password:
      host: localhost
    

    Then in your duplicate User model in your admin site:

    class User < ActiveRecord::Base
      establish_connection "public_#{RAILS_ENV}"
    end
    

    Your duplicate model will now be pulling data from your public database. You will also likely need to define a development and test version of your public database in your database.yml e.g.:

    public_development:
      adapter: postgresql
      database: public_development
      username: blah
      password:
      host: localhost
    

    If you don’t want to duplicate your User model, you can pull it out into a separate gem and make that gem a Rails engine. You will then be able to include that gem into both your public and admin site and have the model be available in both. However if you do things this way you will need to have the extra database definitions in both your public and your admin project (since the User model will still need the establish_connection bit).

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

Sidebar

Related Questions

I am working on a public-facing web site which serves up articles for people
I have a working web app which can do search for User objects through
I'm working on a web app which is heavy on the client side, which
I am working on a web app which makes use of a 3rd party
Working on a basic C# web app here and I can't seem to get
I am working on a web app that uses Perl and I need to
I'm working on a web app that is somewhere between an email service and
I'm working on a web app project (in java; not that it matters) and
I am working on a web app using C# and asp.net I have been
I'm working on a web app and I need to get a div to

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.