Skip to content

Instantly share code, notes, and snippets.

@JakeAustwick
Created September 7, 2012 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JakeAustwick/3669643 to your computer and use it in GitHub Desktop.
Save JakeAustwick/3669643 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
# Other stuff removed
belongs_to :plan
belongs_to :stripe_plan
def plan
self.stripe_token.to_s == "0" ? self.plan : self.stripe_plan
end
# Other stuff removed
end
1.9.2-p290 :001 > User.first.plan
User Load (0.7ms) SELECT `users`.* FROM `users` LIMIT 1
SystemStackError: stack level too deep
from /Users/Jake/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/irb/workspace.rb:80
Maybe IRB bug!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment