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 7645045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:50:22+00:00 2026-05-31T09:50:22+00:00

I learned ruby on rails before php and need a quick answer. I’m trying

  • 0

I learned ruby on rails before php and need a quick answer.

I’m trying to do something like this in CakePHP.

@foo = Foo.find(:all)
@some_foos = @foo.select { |i| i.status == 4 }

Thanks!

  • 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-31T09:50:23+00:00Added an answer on May 31, 2026 at 9:50 am

    Roughly translates to:

    $foo = Foo::find($all);
    $some_foos = $foo->select(function($i) {
        return $i->status == 4;
    });
    

    In other words, it’s calling the static find method on the Foo ActiveRecord and assigns the result. Then it selects from those results those records which satisfy the anonymous function and assigns those as well.

    Try this for CakePHP (untested):

    $foo = $this->Foo->find('all');
    $some_foos = array_filter($foo, function($i) {
        return $i['Foo']['status'] != 4;
    });
    

    If you dont need all the Foos, you want to fetch the relevant records instead:

    $some_foos = $this->Product->findAllByStatus('4');
    

    or via raw SQL

    $some_foos = $this->Foo->query("SELECT * FROM foo WHERE status = 4;");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So this is my first real Ruby on Rails project. I've learned my lesson
Hoping some learned Rails developers here can recommend an existing Ruby on Rails plugin
After doing some work with Ruby, Rails, and RSpec last summer and I learned
I just learned ruby, and already have some html/javascript/css background. When i learn rails
I'm trying to write a C# repository with atomic contexts and feel like this
In other programming languages (Python, Ruby, Scheme), I'm used to doing things like $foo
I've just started programming in rails 3 days ago, learned ruby by the same
I am a NOOB to Rails 3 and just completed the Ruby-on-Rails tutorial. This
So I'm teaching myself Ruby on Rails, with a PHP background. I've written a
I have recently begun the process of trying to learn Ruby/Rails and have been

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.