Forum: Ruby on Rails Observable notifying a controller.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fc28f609965c93c4b603f747c415c6d8?d=identicon&s=25 Fernando Lujan (Guest)
on 2006-06-08 16:47
(Received via mailing list)
I want to code the following task:

I have a class, for instance, class A with is a observable.

I want to add a controller of my rails system to this class. So I can
notify_observer, and it updates all controllers of my system.

How do I pass a controller as a parameter to the add_observer() method?
And where I put this code?

Thanks in advance.

Fernando Lujan
88ade3846f380b12dc27cada47138661?d=identicon&s=25 Fernando Lujan (Guest)
on 2006-06-08 19:35
(Received via mailing list)
Fernando Lujan wrote:
>
To develop a chat application I have a external class that notify every
user in the chat about a new conversation.
I'm using observer pattern. Now, I want to create a controller in my
rails app. And notify this controller to change the view when it
receives a new action.

How could I implement this?

I need to pass a instance of my classto the controller initialize
method.

def initialize(observable)
    observable.add_observer(self)
end

Where I initialize this instance of my class?

Thanks in advance.

Fernando Lujan
This topic is locked and can not be replied to.