# ROR with C++ Backend

**URL:** <https://www.ruby-forum.com/t/ror-with-c-backend/77617>\
**Category:** Rails\
**Created:** [March 7, 2006, 4:01am UTC](https://www.ruby-forum.com/t/ror-with-c-backend/77617 "2006-03-07T04:01:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![xwordguy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/65b543/32.png) [@xwordguy](https://www.ruby-forum.com/u/xwordguy)\
**Post date:** [March 7, 2006, 4:01am UTC](https://www.ruby-forum.com/t/ror-with-c-backend/77617/1 "2006-03-07T04:01:31Z")

</div>

Is there a fairly simple way to use Ruby on Rails with a C++ backend  
where both the C++ code and the Rails code will have access to a  
database through the same place? I’m trying to write a web interface  
that uses an existing C++ program to do most of the data manipulation  
and calculations, but both the UI and the backend need to be able to  
CRUD the database. Is there a way to do this so that both modules  
access the database using the same code? I’m trying to avoid  
duplicating data validation as much as possible.

One option is to pass everything through the C++ code and let it handle  
the database interractions and then pass the information back to Rails.  
If I were to do it this way, I would be avoiding one of Rails most  
useful features. Also, passing the information this way is not very fun  
to implement.

I was thinking there might be a way to wrap the ActiveRecord code in C++  
somehow so that the backend would just use the same simple database  
interface that rails uses. I’m not sure if this is possible or how to  
do it. Please respond with suggestions on how do do this or any other  
way to implement this system. Thanks.

---

<div class="post-metadata">

**Author:** ![xwordguy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/65b543/32.png) [@xwordguy](https://www.ruby-forum.com/u/xwordguy)\
**Post date:** [March 7, 2006, 5:03am UTC](https://www.ruby-forum.com/t/ror-with-c-backend/77617/2 "2006-03-07T05:03:20Z")

</div>

hi Kevin,

You can use Swig interface and then write ruby wrapper classes, it would  
make the job much easier and use pure ruby code.

If you want to use ActiveRecord it should also not be difficult you just  
need to write a different driver which uses your api in C++ instead of  
db api calls.

thanks  
Vikrant
