Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7499137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:43:00+00:00 2026-05-29T19:43:00+00:00

I have this method: def validates_image_dependents post = self.find(params[:id]) i=0 for this_post in Post.all

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:43:02+00:00Added an answer on May 29, 2026 at 7:43 pm

    Looks like you see nil result in the irb output like this:

    irb(main):018:0> def validates_image_dependents                                                                 
    irb(main):019:1>   post = self.find(params[:id])                                                                
    irb(main):020:1>    i=0                                                                                         
    irb(main):021:1>    for this_post in Post.all                                                                   
    irb(main):022:2>     if this_post.posted_filename == post.post_filename                                         
    irb(main):023:3>      i+=1                                                                                      
    irb(main):024:3>     end                                                                                        
    irb(main):025:2>    end                                                                                         
    irb(main):026:1>  return i > 1                                                                                  
    irb(main):027:1> end                                                                                            
    => nil 
    

    This happens because you defined method validates_image_dependents and definition of method expression returned nil.

    You need to execute your method to get actual result:

    irb(main):028:0> validates_image_dependents 
    => true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have methods in all of my models that look like this: def formatted_start_date
I have this model and modelform: class Comment(models.Model): text = models.CharField(max_length=100) def clean_text(self): print
I have a bunch of python methods that follow this pattern: def delete_session(guid): conn
I have this method on a webpart: private IFilterData _filterData = null; [ConnectionConsumer(Filter Data
I have this method in my db class public function query($queryString) { if (!$this->_connected)
I have this method: public bool CanExecute() And after 70 commits, I added an
I have this method Verify_X which is called during databind for a listbox selected
I have this method: private delegate void watcherReader(StreamReader sr); private void watchProc(StreamReader sr) {
I have this method that changes an larger image source on click. I need
I have this method for grabbing the file name from a string URI. What

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.