Hi Jacob, This mailing list (rubyonrails-core) is intended for discussion about development of the framework itself, not usage of it.
For support issues or usage questions like this one that are not issues with Rails itself, please post to the rubyonrails-talk mailing list ( http://groups.google.com/group/rubyonrails-talk) or somewhere like StackOverflow using the `ruby-on-rails` tag ( http://stackoverflow.com/questions/tagged/ruby-on-rails). You can also drop in to the #rubyonrails channel onirc.freenode.net for realtime help. You'll be more likely to get a quick answer using one of those options. On Sun, Dec 14, 2014 at 11:28 PM, Jacob Tarr <jtarr.r...@gmail.com> wrote: > > 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 > <https://github.com/jacobtarr/lemur>. > > My code: > > *app/controllers/microposts_controller.rb* > > ... > def create > @micropost = current_user.microposts.build(micropost_params) > if @micropost.save > sync_new @micropost > flash[:success] = "Your post has been published!" > else > @feed_items = [] > render 'static_pages/home' > endend > ... > > *app/views/static_pages/home.html.erb* > > <% 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' %> > </aside> > <section class="dashboard__content"> > <%= render 'shared/dashboard/post_widget' %> > <%= render 'shared/dashboard/feed' %> > </section> > </div><% else %> > <% provide(:main_class_modifier, "--homepage") %> > <%= render 'static_pages/home/home_features' %> > <%= render 'static_pages/home/home_newsletter' %><% end %> > > *app/views/shared/dashboard/_feed.html.erb* > > <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: > Micropost.new %> > </ul> > <%= will_paginate @feed_items %> > <% end %> > </div> > </div></div> > > *app/views/sync/microposts/_micropost.html.erb* > > <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> > </div> > <article class="post__content"> > <h6><%= micropost.headline %></h6> > <p><%= micropost.content %></p> > </article> > <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 micropost.date, > :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 %> > </li> > </ul></li> > > *app/views/shared/dashboard/_post_widget.html.erb* > > <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 %> > </div> > </div></div> > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscr...@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.