Skip to content

Instantly share code, notes, and snippets.

@philcrissman
Created February 24, 2011 18:19
Show Gist options
  • Save philcrissman/842600 to your computer and use it in GitHub Desktop.
Save philcrissman/842600 to your computer and use it in GitHub Desktop.
ruby-1.8.7-p299 :027 > a = InternalAd.first
=> #<InternalAd id: 1, title: "An ad for a card", ad_file_name: "1920X1080.jpg", ad_content_type: "image/jpeg", link: "http://localhost:3000/idea_categories/congue-elemen...", ad_file_size: 976133, ad_updated_at: "2011-02-24 17:52:41", publish_at: "2011-02-22 06:00:00", hide_at: nil, created_at: "2011-02-24 17:52:42", updated_at: "2011-02-24 17:52:42">
ruby-1.8.7-p299 :028 > a.link
NoMethodError: Attempt to call private method
from /Users/philcrissman/.rvm/gems/ruby-1.8.7-p299@archivers_intranet/gems/activerecord-2.3.9/lib/active_record/attribute_methods.rb:236:in `method_missing'
from (irb):28
ruby-1.8.7-p299 :029 > a.private_methods.include?("link")
=> true
ruby-1.8.7-p299 :030 > a.methods.include?("link")
=> false
ruby-1.8.7-p299 :031 > a.title
=> "An ad for a card"
ruby-1.8.7-p299 :032 > a.private_methods.include?("link")
=> false
ruby-1.8.7-p299 :033 > a.methods.include?("link")
=> true
# hmmm.
> InternalAd.ancestors.each{|an| puts "#{an}" if an.private_instance_methods.include?("link") }
ActiveRecord::Base
Object
FileUtils
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment