Skip to content

Instantly share code, notes, and snippets.

View jlberglund's full-sized avatar

Jonathan Berglund jlberglund

View GitHub Profile
@jlberglund
jlberglund / settings.xml
Created March 7, 2015 06:29
Sample settings.xml config file for GiftFold
<?xml version="1.0"?>
<settings xmlns="http://giftfold.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://giftfold.com/giftfold_theme_settings.xsd">
<form>
<customization>
<name>fund</name>
<type>string</type>
<value>Disaster Relief</value>
</customization>
</form>
<theme>
@jlberglund
jlberglund / theme.liquid
Created January 28, 2014 07:47
This is an example of a GiftFold theme layout.
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset=utf-8>
<title>{{ page_title }}</title>
<link rel="shortcut icon" href="{{ 'favicon.ico' | asset_url }}" >
{% csrf %}
<meta name="robots" content="noindex, nofollow" />
<link href="{{ 'style.css' | asset_url }}" rel="stylesheet" media="screen" />
@jlberglund
jlberglund / controllers_helper.rb
Created March 20, 2013 18:15
Returns attributes for a factory with associations
# spec/support/controllers_helper.rb
module ControllersHelper
# Since FactoryGirl.attributes_for excludes associations, use FactoryGirl.build and then
# strip out the protected attributes.
def build_attributes(*args)
build_object = FactoryGirl.build(*args)
build_object.attributes.slice(*build_object.class.accessible_attributes).symbolize_keys
end
end
@jlberglund
jlberglund / token_input.rb
Created November 15, 2011 03:42
SimpleForm Custom Input for jQuery Tokeninput
# SimpleForm (https://github.com/plataformatec/simple_form)
# jQuery Tokenninput (http://loopj.com/jquery-tokeninput/)
class TokenInput < SimpleForm::Inputs::Base
def input
input_html_options[:"data-url"] = "/#{reflection.klass.name.tableize}.json"
if @builder.object.send(reflection.name).nil?
if input_html_options[:value]
object = reflection.klass.find(input_html_options[:value])
end
else