Skip to content

Instantly share code, notes, and snippets.

@siliconsenthil
Created November 19, 2013 17:36
Show Gist options
  • Save siliconsenthil/7549197 to your computer and use it in GitHub Desktop.
Save siliconsenthil/7549197 to your computer and use it in GitHub Desktop.
before
class CommentsController < ApplicationController
def create
event_user = EventUser.find(params[:event_user_id])
comment = Comment.create(:event_user => event_user, :text => params[:text])
FayeClient.broadcast("/event_#{event_user.event_id}_comments", comment.as_json)
render :text => 'Success'
end
end
##############################
class Comment < ActiveRecord::Base
belongs_to :event_user
attr_accessible :text, :event_user
delegate :uid, :to => 'event_user.user'
def as_json
super.merge(:uid => uid, :text => ERB::Util.html_escape(text))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment