Skip to content

Instantly share code, notes, and snippets.

plan = '50UserTier'
without_stripe = Company.all.select { |company| company.stripe_rel.nil? }
without_stripe.each { |company| company.create_stripe_relationship plan }
class CreateKeyVals < ActiveRecord::Migration
def change
create_table :key_vals do |t|
t.string :key
t.text :value
t.string :value_type
t.timestamps
end
add_index :key_vals, :key, unique: true
end
@wrightling
wrightling / WebViewController.rb
Created October 16, 2013 19:42
Rubymotion - looking to get past basic http authentication when connecting to a URL with UIWebView..
class WebViewController < UIViewController
def viewDidLoad
super
@url = NSURL.URLWithString("<redacted>")
request = NSURLRequest.requestWithURL(@url)
connection = NSURLConnection.connectionWithRequest(request, delegate: self)
self.view = UIWebView.alloc.init
@wrightling
wrightling / add_card.json
Created May 11, 2013 04:22
Refactoring the request JSON for my rails-api. The "add_card.json" and "update_card.json" files show how my API is currently expecting the request JSON. The "take2" versions are in a format that seems more conformant with jsonapi.org.
{"card":{"subject":"some subject","contents":"longer content to be practiced"}}
@wrightling
wrightling / card.rb
Last active December 17, 2015 00:18
JSON error thoughts
class Card < ActiveRecord::Base
attr_accessible :reference, :scripture, :subject
validates :scripture, presence: true, length: { minimum: 20 }
validate :at_least_one_subject_or_reference
def self.updated_since(time)
if time
Card.where("updated_at >= ?", time)
else
@wrightling
wrightling / design_for_devs.md
Last active December 14, 2015 15:59
CSS, HTML, and Design for a back-end developer. Suggestions from the Ruby Rogues' Parlay list.