Skip to content

Instantly share code, notes, and snippets.

@Woody88
Last active August 29, 2015 14:25
Show Gist options
  • Save Woody88/24fb0fac513dd2aac13c to your computer and use it in GitHub Desktop.
Save Woody88/24fb0fac513dd2aac13c to your computer and use it in GitHub Desktop.
class WebsocketControllers::PostingsController < WebsocketRails::BaseController
def new_post
puts 'message:' + message
post = profile.posts.create!(content: message)
broadcast_message :new_post, format_post(post)
WebsocketRails[:posts].trigger(:new_post, format_post(post))
end
##format_post is not being called
def format_post(post)
p = p.attributes.symbolize_keys!
p[:id] = p.id
p[:profile] = p.profile._id
p[:created_at] = time_ago_in_words(post.created_at)
p[:content] = post.content
p[:user] = {:fname => p.user.fname, :lfname => p.user.lname}
return p
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment