Back

Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
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)

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

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers

500 comments

94.2k users

Browse Categories

...