Hi,
I have to make an observer if a modification is done on 3 differents
classes
Hotel, Server, ServerUser.
class HotelObserver < ActiveRecord::Observer
observe Hotel, Server, ServerUser
def after_create(model)
generate_hotel_param_files
generate_hotel_setup_files
end
def after_update(model)
generate_hotel_param_files
generate_hotel_setup_files
end
…
I need to get the id (hotel id) to make my functions
generate_hotel_param_files and generate_hotel_setup_files.
is it possible to transmit this parameter to generate_hotel_param_files
and
generate_hotel_setup_files,
is it possible to make 3 differents functions
def after_create(hotel), def after_create(server), def
after_create(userserver), or do I have to check model class
How can I do that ?
Thanks
eh, like so?
def after_create(model)
generate_hotel_param_files(model.id)
generate_hotel_setup_files(model.id)
end
def after_update(model)
generate_hotel_param_files(model.id)
generate_hotel_setup_files(model.id)
end
On Jul 21, 9:59 am, David N. [email protected]
Yes, but will it take hotel as the model ?
Jeff Emminger wrote:
eh, like so?
def after_create(model)
generate_hotel_param_files(model.id)
generate_hotel_setup_files(model.id)
end
def after_update(model)
generate_hotel_param_files(model.id)
generate_hotel_setup_files(model.id)
end
On Jul 21, 9:59�am, David N. [email protected]
On Jul 22, 5:00 am, David N. [email protected]
wrote:
Yes, but will it take hotel as the model ?
the argument passed to the observer methods is an instance of whatever
class the observer belongs to, i.e. HotelObserver methods will be
given an instance of Hotel. Is this what you mean?