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 < ActiveRecord::Base
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
class CsrfController < ApplicationController | |
def index | |
render json: { request_forgery_protection_token => form_authenticity_token }.to_json | |
end | |
end |
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
// 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']]; |
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
$(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...', | |
}) | |
}); |