Skip to content

Instantly share code, notes, and snippets.

@JoshDoody
JoshDoody / dpt_init.js
Created October 16, 2017 14:41
DPT_init file showing code to render modal
// setting it up
window.drip_plinko = function(drip, page) {
var response = {}
var context = window.context
if (drip.is_anon) {
if (context == 'raise') {
response = {
offer: 'salary-increase-templates',
@JoshDoody
JoshDoody / gist:174444519da0f8f970f4
Last active August 29, 2015 14:09
Dynamic URL with jQuery TokenInput
$(function() {
$(".submission_user_select").tokenInput(getSearchURL, {
crossDomain: false,
prePopulate: $("#submission_user_id").data("pre"),
hintText: "Type a member name...",
tokenLimit: 1,
propertyToSearch: "full_name",
placeholder: "Type a member name...",
theme: "facebook",
resultsFormatter: function(item){ return "<li>" + item[this.propertyToSearch] + "</li>" },
@JoshDoody
JoshDoody / rails4_unscoped_tests.rb
Created March 13, 2014 15:50
Failing tests for Rails 4 unscoped when used with eager loading (includes). Two assertions should fail: Line 88 and Line 110. Line 88 should pass in Rails 3, but won't in Rails 4. Line 110 leverages the 'unscoped association' added in Rails 4, but still fails.
unless File.exist?('Gemfile')
File.write('Gemfile', <<-GEMFILE)
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'arel', github: 'rails/arel'
gem 'sqlite3'
GEMFILE
system 'bundle'
end
// Set the correct sprite paths
$iconSpritePath: asset-url('glyphicons-halflings.png', image);
$iconWhiteSpritePath: asset-url('glyphicons-halflings-white.png', image);
$navbarBackground: #555;
$navbarBackgroundHighlight: #888;
$navbarText: #eee;
$navbarLinkColor: #eee;
@import "bootstrap";
$("#follow_form").html("<form accept-charset=\"UTF-8\" action=\"/relationships\" class=\"new_relationship\" data-remote=\"true\" id=\"new_relationship\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /><input name=\"authenticity_token\" type=\"hidden\" value=\"vPXMc/5T08MuZ2W3M3WKvVHfptPai/Ux0twZ4USiopk=\" /><\/div>\n <div><input id=\"relationship_followed_id\" name=\"relationship[followed_id]\" type=\"hidden\" value=\"44\" /><\/div>\n <input class=\"follow-button button-border round-5 gray-gradient pointer\" id=\"follow_button\" name=\"commit\" type=\"submit\" value=\"Follow\" />\n<\/form>")
$("#followers").html('0')
class RelationshipsController < ApplicationController
before_filter :authenticate
def create
@user = User.find(params[:relationship][:followed_id])
current_user.follow!(@user)
respond_to do |format|
format.html { redirect_to @user }
format.js
end