Need advice for non-ActiveRecord processing

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 :slight_smile:

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/
? 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
) ?

Fred

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

Cheers,
Jordan

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?