Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Salesforce by (11.9k points)

Currently, I am developing a rails project to connect the database from salesforce.com with our SQL server. Atm, we use the gems 'mysql2' for the SQL part and 'databasedotcom' + 'databasedotcom-rails' for the salesforce part.

Our problem ist, that we have the same names for the tables in both databases. So both adapters try to encapsulate them into ActiveRecord classes and as you guess, it's a big problem. Unfortunately, we found no solution on the internet. So how can I prevent the namespaceconfict?

1 Answer

0 votes
by (32.1k points)
edited by

Try to use the following code, it might work for you:

class Account < ActiveRecord::Base

  # table name is 'accounts' in mysql db

end

class SalesForceAccount < ActiveRecord::Base

  establish_connection "#{Rails.env}_salesforce"

  table_name = :accounts

end

Using a database.yml of

development:

  # your mysql credentials and adapter info

development_salesforce:

  # your salesforce credentials and adapter info

Enroll in this Salesforce certification today to become a professional in Salesforce!

Browse Categories

...