i have a controller (User controller), this is used to create update and delete a user from db. Within the UserObserver class after_save is been defined as a method in UserObserver after each save in db i have to call another application through http with user_details(in hash format)
class UserObserver < ActiveRecord::Observer
def after_save user_details
begin
http Net::HTTP.new("localhost", "8000")
request = Net::HTTP::Post.new("/verification")
request.add_field('Content-Type', 'application/json')
request.body = user_details.to_json
response = http.request(request)
@http_error = false if response.code == 200
rescue Exception => error
@http_error = true
end
end
end
i need to access @http_error variable in user_controller to know status of http request been made so that furthur action can be taken according to it.