Skip to content

Instantly share code, notes, and snippets.

View landlessness's full-sized avatar

Brian S. Mulloy landlessness

View GitHub Profile
require 'spec'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8 />
<title>Font Size Experiments</title>
<style type="text/css">
span {margin:0;padding:0;}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script>
person = Person.first
add_on = AddOn.first
person.add_ons.exists?(add_on)
person = Person.first
person.add_ons
class Person
# ...
def add_ons
AddOn.joins(:pricing_plans => {:subscriptions => :person}).where(:subscriptions => {:person_id => self})
end
# ...
end
# i started with the following, which i thought would work with no problem:
AddOn.joins(:pricing_plans).joins(:subscriptions)
# returned this error:
# ActiveRecord::ConfigurationError:
# Association named 'subscriptions' was not found; perhaps you misspelled it?
# trying to get at it from the other direction:
PricingPlan.joins(:subscriptions).joins(:person)
# of course this didn't work either
# ActiveRecord::ConfigurationError: Association named 'person' was not found; perhaps you misspelled it?
class AddOn < ActiveRecord::Base
has_many :pricing_plans, :dependent => :destroy
end
class PricingPlan < ActiveRecord::Base
has_many :subscriptions
end
class Subscription < ActiveRecord::Base
belongs_to :person
select * from add_ons
inner join pricing_plans on add_ons.id = pricing_plans.add_on_id
inner join subscriptions on pricing_plans.id = subscriptions.pricing_plan_id
inner join people on people.id = subscriptions.person_id
where people.id = 1
$(document).ready(function(){
if ($('.resize-font').length) {
$(window).resize(resize);
resize();
}
});
function resize() {
// sizeCoefficient lets me decide how big the fonts are.
// 0.75 gives about 10 words per line, which is good design
# remove the github gem pointers
gem 'foo', :git => 'github.com/...'