Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

erb code not execute on partial after broadcasting #108

Open
matzavinosg opened this issue Dec 30, 2014 · 0 comments
Open

erb code not execute on partial after broadcasting #108

matzavinosg opened this issue Dec 30, 2014 · 0 comments

Comments

@matzavinosg
Copy link

I am using faye rails but I believe that the same problem will be with private pub. Following the railscast the users can send messages to each other but I want to mark the messages as read when the recepient receives it. I added some ruby code on the partial because I thought that when the message is evaluated on the recipient wil be executed too. But it not working..

application.js:

$(function() {
var faye = new Faye.Client('http://xxxip/faye');
faye.subscribe('/messages/<%= @conversation.faye_token%>', function (data) {
eval(data);
});
});

create.js.erb:

<% broadcast "/messages/#{@conversation.faye_token}" do %>
$("#chat").append("<%= j(render('message', :message=> @message)) %>");
<% end %>
$('#message_body').val('');

and the partial I am rendering:

<%= message.body %> at <%= message.created_at.strftime("%H:%M, %d %b") %>

<%if message.recipient_id.to_s == session[:user_id].to_s%>
<%message.reading%>
<%end%>

But the ruby code is executed on the recepient only if I reload the whole page.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant