[Shooting-star-users] Shooting-star and rails metor_strike plugin

Jon Evans jon.evans at pobox.com
Wed Aug 8 16:25:08 EDT 2007


Hi,

I have a rails project where users can view and edit tables of information.
It already has an AJAX component to update the database on the server when a
cell in the table is edited, what I want to implement with shootingstar is a
system to refresh the table in any open browsers when one user edits it. So,
if 5 people are viewing the same table of information and one user makes an
edit, the other four browsers tables get updated with the new information.

I think I've nearly got it - I now have a javascript alert in each browser
when other users connect and disconnect. What I can't work out how to do is
send a message to all open browsers when a record gets updated.

I would also appreciate any advice as to whether I'm coding this the right
way.

My view contains the following code for testing:

<%=
meteor_strike 'appname/model',
  :uid => session.session_id,
  :tag => [@model.id],
  :event => %Q{
    switch(params.event){
    case 'enter':
      /* params.uid is entered to the channel with params.tag */
      alert("enter: " + params.uid + ", " + params.tag);
      break;
    case 'leave':
      /* params.uid is left from the channel with params.tag */
      alert("leave: " + params.uid + ", " + params.tag);
      break;
    case 'update':
      /* params.uid is updated status in the channel */
      alert("update: " + params.uid);
      break;
    otherwise:
      alert(params.event + "event fired");
    }
  }
%>

The code I'm trying in my controller, called when a record is updated, is:

    # this javascript updates the grid
    javascript = "grid.updateFromXML('/model/#{@model.id}')"
    Meteor.shoot 'appname/model', javascript, [@model.id]

This doesn't work at all, the viewers never get any kind of notification
message. It does create a new row in the meteors table though.

Thanks

Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/shooting-star-users/attachments/20070808/1ff5ba7c/attachment.html 


More information about the Shooting-star-users mailing list