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

  • Home
  • SEARCH
  • 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 8971507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:58:28+00:00 2026-06-15T17:58:28+00:00

I am creating a ‘match.com’ style app for local dog adoptions, where a user

  • 0

I am creating a ‘match.com’ style app for local dog adoptions, where a user or a dog can create a profile. In each profile, there are boolean fields. I want to display the correct dog that has the same true value in the dog profile with the corresponding boolean field in the user profile. In the example, if Dog.kids_under_10 and User.profile.kids_under_10 match, the dog is displayed. I can accomplish this with a String or Integer (1 or 0), but I am trying to learn the best way to write code.

I will eventually be passing additional params, but I think once I understand how to make the below example functional, I should be able to simply add params as needed using the same logic.

Controller:

@user = current_user.profile
@dogs = Dog.by_profile(params[@user.kids_under_10])

Model:

def self.by_profile(user_profile)
  Dog.where('kids_under_10 = ?', user_profile )
end
  • 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-06-15T17:58:29+00:00Added an answer on June 15, 2026 at 5:58 pm

    Your @dogs assignment can look like this

    @dogs = Dog.where(kids_under_10: @user.kids_under_10)
    

    There is no need for your by_profile class method.


    If you want to keep the class method, your controller would look like this

    @user = current_user.profile
    @dogs = Dog.by_profile(@user)
    

    and your model’s class method, like this

    def self.by_profile(user_profile)
      return [] if user_profile.nil?
      Dog.where(kids_under_10: user_profile.kids_under_10)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating a web interface so our helpdesk can create users and setup some of
creating a very simple scheduling app I am asking the user to tell me
Creating an a app, where I store bunch of photos in the drawable folder,
Creating a google map with store locations within 50 miles of user entered address.
Creating a Blackberry app. Just a beginner, I have searched but couldn't find a
Creating a site in with FrogCMS and using alot of jquery to create an
Creating an iOS app in Flash Builder 4.5 which is a small Hello World
Creating an ATL project in MSVC seems to create not one but two projects;
I'm creating a web service to transfer json to an iPhone app. I'm using
Creating a searchable contacts kind of app. Below is my code public class EmployeeList

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.