Reputation: 14625
I got the following situation:
I have a rails application and two databases, one is for the Rails Application and the second database (running on the same DB Server Instance) is for a different non-web application.
My Rails Web Application may read from the (second) Database directly via SQL but it can't write to it because of security restrictions (the data has to be validated by the non-web application). So we wrote a little CLI interface based on SOAP for writing into the database.
My question is: Can I extend the ActiveRecord Model (Rails 3) in a way so that the reading goes as normal over the SQL connection but update/create/delete goes over our selfmade interface.
Upvotes: 1
Views: 1162
Reputation: 14625
I think I found a good solution :)
@ rtacconi: Thanks for your links but since Rails 3 you don't have to use these extensions because ActiveModel works table-less out of the box :)
I need full ActiveRecord support for reading the table but writing is done over my SOAP interface. This is because I can't validate the data in my Rails application.
So my solution is to overload the ActiveRecord::Persistence Module (can be found in activerecord-3.0.0/lib/active_record/persistence.rb.
This module is responsible for any write tasks to the DB connection. So instead of writing to the DB, my Persistence Layer calls the SOAP interface.
Best regards
Simon
Upvotes: 1
Reputation: 14789
You could implement a tableless model: ActiveRecord::Base Without Table or http://github.com/AnthonyCaliendo/acts_without_database
Than you can set/get data into an object using the SOAP library.
Upvotes: 0