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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:19:12+00:00 2026-06-09T04:19:12+00:00

Basically I need to connect to another app’s database, I’ve done the connection in

  • 0

Basically I need to connect to another app’s database, I’ve done the connection in config/database.yml, that database is not from a rails app so for starters the table names are not pluralized and also I’d need to add the establish_connection to all of them, I tried to create a parent class and Inherit the others from it but I just can’t get it right, keeps complaigning that the parent one doesn’t have a table, if i add abstract_class to it then the child modules are abstract as well -.-

How can DRY it up a bit

Update

This worked …

class QB < ActiveRecord::Base
  self.abstract_class = true
  establish_connection 'quickbooks'

  def self.pluralize_table_names
    false
  end
end

not quite sure why the pluralize_table_names had to be that way, but it works, thanks for the hint on the abstract_class @zetetic

Update

Used this in the parent class, better for my case

def self.table_name
    self.name.gsub(/QB::/,'').downcase
end
  • 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-09T04:19:14+00:00Added an answer on June 9, 2026 at 4:19 am

    if i add abstract_class to it then the child modules are abstract as
    well

    This should not be the case. self.abstract_class = true sets an instance variable in the class singleton, a ‘class instance variable’. This is not shared by subclasses:

    class A < ActiveRecord::Base
      self.abstract_class = true
    end
    
    class B < A; end
    
    A.abstract_class # true
    B.abstract_class # nil
    

    This Martin Fowler blog post describes what is going on in more detail.

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

Sidebar

Related Questions

Basically I need to connect to the database without any existing databases. In SQL,
I need to connect to another web application using webservice. That web application uses
I am building a ado.net wrapper that can connect with any database(supported by ADO.Net)basically
my database config has changed so Magento is not able to connect anymore. The
basically need to change the value that - admin_url() returns any idea?
Basically I need to capture the video from videocamera do some processing on frames
I am working on a simple hobby project that checks when users connect/disconnect from
I am attempting to connect to a SQL Server 2008 R2 instance from another
How to achieve Oraclel's CONNECT BY PRIOR output using LINQ? Basically i need the
Basically I need a suggestion about making an iOS application, where I can connect

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.