Hey all. I think I flooded #rubyonrails too much I'm not getting
replies anymore.. hehe.
Let's say I have two models: Idea and IdeaImage. Idea has_many
:idea_images and IdeaImage belongs_to :idea. Here's my question: how
do I allow deletion _only if_ there is more than 1 idea_image left in
idea?
def validate_as_destroyable
debugger
if idea.idea_images.size <= 1
return false
end
end
in the debugger i type idea. it works. i type idea.idea_images. it
works. in my log i still get the same error though...
NoMethodError (You have a nil object when you didn't expect it!
The error occurred while evaluating nil.idea_images):
/app/models/idea_image.rb:25:in `validate_as_destroyable'