Using the Sync gem to make restful Rails app real-time

I’ve made a functional mini social network app in Rails. I’m using the Sync gem in order to make my app realtime so that when a user posts something, it’ll immediately show up on their home feed. I feel like I’m extremely close to making this work. The form works and there are no run-time errors with the below code. However, when the current user posts something, it doesn’t appear on the home page unless the page is refreshed. If it’s any help, I’m using Michael Hartl’s system to do this. What am I doing wrong here? Thanks for your help in advance. If I missed a piece of code that I should I have put here, the repository is on GitHub - jacobtarr/lemur: A social network that allows users to post events and news.

My code:



def create
@micropost =
  if @micropost.    save
sync_new @micropost
    flash[:success] = "Your post has been published!"
    @feed_items = []
    render 'static_pages/home'



<% provide(:title, "Home") %>
<% if logged_in? %>
<% provide(:main_class_modifier, "--dashboard") %>
<div class="dashboard">
        <aside class="dashboard__sidebar">
            <%= render 'shared/dashboard/current_user_info' %>
<%= render 'shared/dashboard/account_settings' %>
        <section class="dashboard__content">
            <%= render 'shared/dashboard/post_widget' %>
<%= render 'shared/dashboard/feed' %>
<% else %>
<% provide(:main_class_modifier, "--homepage") %>
<%= render 'static_pages/home/home_features' %>
<%= render 'static_pages/home/home_newsletter' %>
<% end %>


<div class="dashboard__content--feed-section">
    <div class="pagelet">
        <div class="pagelet__header"><i class="fa fa-rss"></i>Your Feed</div>
        <div class="pagelet__body">
            <% if @feed_items.any? %>
<ul class="posts-list">
                    <%= sync partial: 'micropost', collection: @feed_items %>
<%= sync_new partial: 'micropost', resource: %>
              <%= will_paginate @feed_items %>
<% end %>


<li class="post" id="post-<%= micropost.    id %>">
<div class="post__avatar">
        <%= link_to gravatar_for(micropost.user, size: 100), micropost.        user %>
<span><%= link_to at_username micropost.user %></span>
    <article class="post__content">
        <h6><%= micropost.headline %></h6>
        <p><%= micropost.content %></p>
    <ul class="post__meta-info">
        <li><i class="fa fa-clock-o"></i><%= time_ago_in_words(micropost.created_at) %> ago</li>
        <li><i class="fa fa-calendar-o"></i><%= I18n.l, :format => :default %></li>
        <li><i class="fa fa-map-marker"></i><%= micropost.location %></li>
        <li class="post__meta-info--delete">
        <% if current_user?(micropost.user) %>
<%= link_to '<i class="fa fa-trash-o"></i>Delete'.html_safe, micropost,
                                             remote: true,
                                             method: :delete,
                                             data: { confirm: "You sure?" } %>
<% end %>


<div class="dashboard__content--post-section">
    <div class="pagelet">
        <div class="pagelet__header"><i class="fa fa-pencil"></i>Post</div>
        <div class="pagelet__body">
            <%= form_for @micropost, html: { class: "post-section__form" }, remote: true do |f| %>
<%= f.submit "Post", class: "btn btn__primary btn__lg btn__post" %>
<% end %>

You are not syncing, you are rendering.

In practice, one simply only needs to replace:

<%= render partial: 'user_row', locals: {user: @user} %>


<%= sync partial: 'user_row', resource: @user %>