I have this method:
def validates_image_dependents
post = self.find(params[:id])
i=0
for this_post in Post.all
if this_post.posted_filename == post.post_filename
i+=1
end
end
return i > 1
end
I want the method return true or false dependend if i > 1, but I get nil.
What am I doing bad?
Without method works fine.
Thank you
Looks like you see
nilresult in the irb output like this:This happens because you defined method
validates_image_dependentsand definition of method expression returnednil.You need to execute your method to get actual result: