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
#turn on our autocompletes if there are any | |
jQuery -> | |
if $('#user_autocomplete').length | |
index = 1 | |
$('#user_autocomplete').autocomplete | |
source: (request, response) -> | |
#add our custom index parameter to the call | |
request["index"] = index++ | |
#make our request and handle the response as normal | |
$.ajax( |
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
// Debounced autosave for Ember.js | |
// Original code by Mitch Lloyd http://gaslight.co/blog/?author=mitchlloyd | |
// updated from http://gaslight.co/blog/an-autosave-pattern-for-ember-and-ember-data | |
// repo at https://github.com/gaslight/ember-autosaving | |
// Changed to work with latest Ember Data as of 2013-12-16 by Genkilabs | |
// Includes hooks for pacifier from http://ricostacruz.com/nprogress | |
// NOTE: This requires a 2 part install in which the controller and any models it loads have the corresponding mixin | |
// This is how long we will wait on a form before saving. I like to put this in App.AUTOSAVE_DELAY | |
var AUTOSAVE_DELAY = 1500 |
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
//= require jquery | |
//= require jquery_ujs | |
//= require_tree . | |
// ^ I am assuming that bootstrap3-dialog is in the tree | |
//GLOBAL JQuery Functaionality | |
$(function(){ | |
/*** CONFIRM MODAL OVERRIDE ***/ | |
//override the use of js alert on confirms |
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
#This is how it might be used. Create your instance which could be polymorphic or just a class. | |
#Search using the predicate 'in' because the subquery find_term will return an ID of every record that matches. | |
@profile_instance = either a PetProfile or an OwnerProfile | |
@profile_instance.search( { :find_term_in => "has fleas", :other_ransack_term_eq => "foobar" } ).results() |
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
// app/initializers/simple-auth-config.js | |
export default { | |
name: 'simple-auth-config', | |
before: 'simple-auth', | |
initialize: function() { | |
var tokenEndpoint = '/users/sign_in'; | |
MyAppnameENV['simple-auth'] = { | |
authorizer: 'simple-auth-authorizer:devise', | |
crossOriginWhitelist:[ |
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
#!/bin/bash | |
cd ../../coalesce; | |
npm run-script build; | |
cd ../coalesce-ember; | |
# Hack to use the latest version of Coalesce | |
cp ../coalesce/dist/* bower_components/coalesce/ | |
npm run-script build; | |
cd ../ember-cli-coalesce-todos/client; | |
mkdir -p vendor/coalesce-ember |
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
#Alias the default boolean? operator of ruby for everything so all objects responds_to? :to_bool | |
#...then further refine it for specific classes later | |
class Object | |
def to_bool | |
return !!self | |
end | |
end | |
#Lets give String a custom to_bool that is in line with the meaning for our specific program | |
class String |
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 User < ApplicationRecord | |
rolify :strict => true, :before_add => :before_add_role | |
#Helper method to remove any existing role this user has for a resource | |
def remove_all_roles resource | |
# README: This syntax relies on changes on the following PR | |
# https://github.com/RolifyCommunity/rolify/pull/427 | |
# Or include the source of this directly: | |
# gem 'rolify', :git => "git://github.com/Genkilabs/rolify.git" | |
remove_role nil, resource |
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
#/config/initializers/inflections.rb | |
# This is a nice-to-have so API doesn't keep showing up as Api | |
ActiveSupport::Inflector.inflections(:en) do |inflect| | |
inflect.acronym 'API' | |
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
#An overly complex example of dynamically micro-managing which templates are shown.. | |
class ApplicationController < ActionController::Base | |
# In this example we assume a using Devise so user_signed_in? and current_user are provided. | |
# Note: the value returned here could very well be a user's uuid if you needed to provide | |
# one specific different view for a single or small collection of specific users. | |
# @returns String || nil | |
def get_custom_view_name | |
#This doesn't need to be lazy, but it can be. | |
@custom_view_name ||= begin |
OlderNewer