Skip to content

Instantly share code, notes, and snippets.

@mcollie1
Created April 17, 2014 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcollie1/11010638 to your computer and use it in GitHub Desktop.
Save mcollie1/11010638 to your computer and use it in GitHub Desktop.
<h1><%= @topic.name %></h1>
<% if policy(@topic).update? %>
<%= link_to "Edit Topic", edit_topic_path, class: 'btn btn-success' %>
<% end %>
<div class="row">
<div class="col-md-8">
<p class="lead"><%= @topic.description %></p>
<%= render @posts %>
<%= will_paginate @posts %>
</div>
<div class="col-md-4">
<% if policy(Post.new).create? %>
<%= link_to "New Post", new_topic_post_path(@topic), class: 'btn btn-success' %>
<% end %>
<% if policy(@topic).destroy? %>
<%= link_to "Delete Topic", @topic, method: :delete, class: 'btn btn-danger', confirm: 'Are you sure you want to delete this topic?' %>
<% end %>
</div>
</div>
<script> blocmetrics.track("Topic Views", {topic_name: getAttribute('name'), created_at: getAttribute(created_at) })
(function (){
// track a client-side event using the Blocmetrics analytics service
var _bm_event = {
name: "Topic Views",
topic_name: getAttribute('name'),
created_at: getAttribute('created_at')
}
var _bm_request = new XMLHttpRequest();
_bm_request.open("POST", "http://localhost:3000/events.json", true);
_bm_request.setRequestHeader('Content-Type', 'application/json');
_bm_request.onreadystatechange = function() {
// this function runs when the Ajax request changes state.
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest
};
_bm_request.send(JSON.stringify(event));
}());</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment