Created
April 18, 2014 22:37
-
-
Save mcollie1/11067296 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function (){ | |
// track a client-side event using the Blocmetrics analytics service | |
var _bm_event = { | |
name: "Topic Views", | |
topic_name: "<%= @topic.name %>", | |
created_at: "<%= @topic.created_at %>" | |
} | |
var _bm_request = new XMLHttpRequest(); | |
_bm_request.open("POST", "http://collier-blocmetrics.herokuapp.com/events", 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> | |
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment