1

I trying make notification system and have problem

I need publish notification to the view with this: track_activity.js.erb

<% publish_to "/notifications/new" do %>
  $("#activity").append("<%= j render(@activity) %>");
<% end %>

and my application_controller with action track activity

def track_activity(user, trackable, action = params[:action], author = current_user)
    @activity =  Activity.create! user: user, trackable: trackable, action: action, author: author
  end

and i using this methos every time when oher user create something like this

comment_controller.rb

def create
        @post = Post.find(params[:post_id])
        @comment = @post.comments.build(comment_params)
        @comment.user = current_user
        if @comment.save
            track_activity @post.user, @comment
            redirect_to post_path @post
        else
            render 'new'
        end
    end

How to attach track_activity.js.erb every time when rails call track_activity action? respond_to in track_activity action doesn't help

  • What you actually want to achieve? You want to render js and redirect also ? – Nikita Singh Oct 10 '14 at 13:51
  • I want push notification in real time with private_pub this code work alert works but doesn't render @activity :) –  Oct 10 '14 at 13:58

0 Answers0