-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Hi Dennis,
In the docs, you say:
The index action will expect an instance variable with the same name as your controller in the plural form (e.g. @messages in a MessagesController)
The show, create, update, and destroy actions will expect an instance variable with the singular name of your controller (e.g. @message in a MessagesController)
What about custom actions? How do I return a collection to the client?
With the following code, I get nothing on client:
Rails:
def since
broadcast do
since = chat_room_since
@chat_rooms = []
@chat_rooms = ChatRoom.where("last_time > ?", since).to_a if since
end
end
private
def chat_room_since
date = URI.decode params.require(:date)
DateTime.parse(date) if date
end
Angular:
since: function(dateString, cback) {
if (!sinceSocket) {
sinceSocket = new WebSocket(BASEURL + '/chat_rooms/since');
sinceSocket.onopen = function (data) {
sinceSocket.send(JSON.stringify({date: dateString}));
}
}
sinceSocket.onmessage = function (data) {
if (data.err) {
console.log('Chatrooms: create: error: ',err);
}
if (cback) cback(data);
};
},
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels