This file contains hidden or 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 'spec' |
This file contains hidden or 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
| <!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> |
This file contains hidden or 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
| person = Person.first | |
| add_on = AddOn.first | |
| person.add_ons.exists?(add_on) |
This file contains hidden or 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
| person = Person.first | |
| person.add_ons |
This file contains hidden or 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 Person | |
| # ... | |
| def add_ons | |
| AddOn.joins(:pricing_plans => {:subscriptions => :person}).where(:subscriptions => {:person_id => self}) | |
| end | |
| # ... | |
| end |
This file contains hidden or 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
| # 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? |
This file contains hidden or 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 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 |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| $(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 |
This file contains hidden or 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
| # remove the github gem pointers | |
| gem 'foo', :git => 'github.com/...' |