Hello everybody, By default doing like this: person = Person.new person.name = "John" person.save! Will cause a new row to be inserted into database. But I don''t want it to be saved into DB, instead when "save!" method is called I want to connect to a particular URL and post data to it. For instance: POST http://my.app/people/create "name" => "John" I need this because I don''t have write access to my DB. The obvious way to do it is override save, save!, create and delete methods. but I wonder if there is more convenient way to do it. Thanks! Vlad. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
If you need to do all interactions with your persistence layer via http, 
this is a job for ActiveResource, not ActiveRecord.
If you just need to override the save method, then you can monkeypatch 
by overriding the create_or_update method:
class Person < ActiveRecord::Base
  def create_or_update
    # do what you need to do here
  end
end
Just make sure that you check the rails code for create_or_update so 
that you know what functionality you''re replacing, so that your new 
method will do what it is supposed to without breaking other save calls.
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Thanks! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---