25-09-2008
Check if object has associated attribute method
Section:
Ruby on Rails
if you want to check if an object has an associated attribute method:
if a person has_one image and a gallery has_many images:
gallery.respond_to?(:images)
# => true
gallery.respond_to?(:image)
# => false
person.respond_to?(:images)
# => false
person.respond_to?(:image)
# => true
Sections
-
PHP
(1)
-
General
(2)
-
Ruby on Rails Snippet
(3)
-
Ruby on Rails
(13)
-
HTML
(1)
-
Css
(1)
-
regex
(1)
-
Photoshop
(1)
-
Leopard
(1)
A little note to Internet Explorer users:
This site is not made for Internet Explorer. Some pages may look like shit. Yes, i could fix it for IE, but no, I'm not gonna do it. Try
Opera
or
Firefox
instead!
Welkom
Guest
|
Login