Skip to content

Instantly share code, notes, and snippets.

View leepfrog's full-sized avatar

Andy Tran leepfrog

View GitHub Profile
class CsrfController < ApplicationController
def index
render json: { request_forgery_protection_token => form_authenticity_token }.to_json
end
end
class VotesController < ApplicationController
  def create
    @vote = Vote.find_or_initialize_by_submitted_by_ip(request.remote_ip)
    @vote.update_attributes(params[:vote]) if !@vote.has_user?(session[:user_id])
    render json: @vote
  end
end

class Vote &lt; ActiveRecord::Base
// In this sorting function, we have three indices in our array
// a[0] - the name of the injection
// a[1] - the name of an injection that THIS injection should be before
// a[2] - the name of an injection that THIS injection should be after
// When given an array:
// [['b', 'c', null], ['a','b', null], ['d', null, 'c'], ['c', null, null], ['e', null, 'd']];
// Then the output from this array should look like:
// [['a','b', null], ['b', 'c', null], ['c', null, null], ['d', null, 'c'], ['e', null, 'd']];
$(document).ready(function() {
$('.team_title').editable("name", {
type : 'text',
rows : 8,
authenticity_token: encodeURIComponent('<%= form_authenticity_token if protect_against_forgery? %>'),
cancel : 'Cancel',
submit : 'OK',
tooltip : 'Double-click to edit...',
})
});