# Need advice for non-ActiveRecord processing

**URL:** <https://www.ruby-forum.com/t/need-advice-for-non-activerecord-processing/135966>\
**Category:** Rails\
**Created:** [April 27, 2008, 7:09am UTC](https://www.ruby-forum.com/t/need-advice-for-non-activerecord-processing/135966 "2008-04-27T07:09:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nateleavitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3bc359/32.png) [@nateleavitt](https://www.ruby-forum.com/u/nateleavitt)\
**Post date:** [April 27, 2008, 7:09am UTC](https://www.ruby-forum.com/t/need-advice-for-non-activerecord-processing/135966/1 "2008-04-27T07:09:59Z")

</div>

Hey Guys… need some advice on the best way to set things up. I’ll  
explain my scenario below:

I have a rails app that does some processing through an xmlrpc API  
connection with a third party application where I store the information.  
I created a plugin that loads the API classes I created which contain  
all the available methods through the API. It all works great, but my  
question arises from how to go about certain things when using this  
setup. For example, I have a basic form on the website where all the  
processing goes through the api. Right now, I have that processing code  
in my controller because I have no model. But the problem occurs when I  
want to do things (like validation) that are only available when I only  
have an ActiveRecord model. I guess my questions are:

1. Is it possible to create a model that extends ActiveRecord::Base and  
overrides the save method to go through the API connection instead of  
going to the local database?

2. If that is possible, is that still the best way to do it?

3. If not, what would be the best way going about this?

Please advise 🙂

---

<div class="post-metadata">

**Author:** ![nateleavitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3bc359/32.png) [@nateleavitt](https://www.ruby-forum.com/u/nateleavitt)\
**Post date:** [April 27, 2008, 1:51pm UTC](https://www.ruby-forum.com/t/need-advice-for-non-activerecord-processing/135966/2 "2008-04-27T13:51:45Z")

</div>

On 27 Apr 2008, at 06:09, Nate L. wrote:

> setup. For example, I have a basic form on the website where all the  
> overrides the save method to go through the API connection instead of  
> going to the local database?

I think Activerecord is really quite tied into the sql-ness. Have a  
look at  
[http://rorblog.techcfl.com/2008/04/02/custom-form-validations-without-activerecord/](http://rorblog.techcfl.com/2008/04/02/custom-form-validations-without-activerecord/)  
? I also remember seeing (but I can’t remember where) an approach  
where you essentially just include the module from Activerecord that  
provides validations into your own model (plus write a few stubs that  
the validations stuff expects to find).

> 1. If that is possible, is that still the best way to do it?
> 
> 2. If not, what would be the best way going about this?

Subvert ActiveResource or look at the work that leethal has been doing  
on active model  
([http://github.com/leethal/rails/commits/activemodel\_cleanup](http://github.com/leethal/rails/commits/activemodel_cleanup)  
) ?

Fred

---

<div class="post-metadata">

**Author:** ![nateleavitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3bc359/32.png) [@nateleavitt](https://www.ruby-forum.com/u/nateleavitt)\
**Post date:** [April 27, 2008, 3:00pm UTC](https://www.ruby-forum.com/t/need-advice-for-non-activerecord-processing/135966/3 "2008-04-27T15:00:02Z")

</div>

Try out Validatable ([http://validatable.rubyforge.org/](http://validatable.rubyforge.org/))  
Hope that helps.

Cheers,  
Jordan

---

<div class="post-metadata">

**Author:** ![nateleavitt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3bc359/32.png) [@nateleavitt](https://www.ruby-forum.com/u/nateleavitt)\
**Post date:** [April 27, 2008, 3:53pm UTC](https://www.ruby-forum.com/t/need-advice-for-non-activerecord-processing/135966/4 "2008-04-27T15:53:03Z")

</div>

Thanks for the replies!

I’ll look into your suggestions.

Also, another question I have is should I be creating a model for the  
information I’m collecting on the forms?.. or is it ok to just put the  
processing information into the controller?
