Sync : Real-time partials with Rails

Add Gem:
Faye:
gem 'faye'
gem 'thin', require: false
gem 'sync'

OR

Pusher:
gem 'pusher'
gem 'sync'
Install Sync:
bundle
rails g sync:install
Include:
Application.js:
//= require sync
Application.html.rb:
Ruby > 2.0.0 ::  <%= include_sync_config %>
Ruby <= 2.0.0 ::  <%#= javascript_include_tag Sync.adapter_javascript_url %>

Model:
sync :all


Controller:
To apply on all action : enable_sync

Add on individual action : sync_new / sync_update / sync_destroy 


Html page:
For Post model show/index page:
Show/Update :: <%= sync partial: 'post', collection: Post.all %>     
New :: <%= sync_new partial: 'post', resource: Post.new %>
Sync Server:

rackup sync.ru -E production

Reference Realtime render partials in Rails with Sync

About the author

Being the CEO and Founder of ClecoTech International, Mr. Ashish Prajapati is dedicated towards his aim of mentoring young startups into a full-fledged businesses. He is helping startups from America, Europe, India, and various other countries through proper guidance and the use of latest technologies to develop their innovation and ideas into definite realities.

Leave a Reply

Your email address will not be published. Required fields are marked *