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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:49:33+00:00 2026-05-29T04:49:33+00:00

I have a model, recipe. Here’s the model; https://github.com/mikeyhogarth/Nomelette/blob/master/app/models/recipe.rb I am able to use

  • 0

I have a model, “recipe”. Here’s the model;

https://github.com/mikeyhogarth/Nomelette/blob/master/app/models/recipe.rb

I am able to use dynamic finders to write code like this;

Recipe.find_all_by_name "spaghetti bolognaise"

but the following gives me a “NoMethodError”

Recipe.find_all_by_category 1

As you can see from the model I’ve had to revert to creating my own finder method for this functionality. Am I just missing something with the syntax or will dynamic finders only work on properties that are columns specific to a given model (not associations)?

  • 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-29T04:49:41+00:00Added an answer on May 29, 2026 at 4:49 am

    Recipe doesn’t have a column/attribute named ‘category’ (because it’s a many-to-many association), thus the method find_all_by_category isn’t generated.

    Here’s what you can do

    recipes = Category.find(1).recipes
    

    It would have been different if a Recipe belongs_to :category and Category has_many :recipes. In this case:

    recipes = Recipe.find_all_by_category_id(1)
    

    Because the recipes table has a column named category_id…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following classes: Ingredients, Recipe and RecipeContent... class Ingredient(models.Model): name = models.CharField(max_length=30,
I have a model with a custom property class RecipeIngredient(models.Model): recipe = models.ForeignKey(Recipe) ingredient
I have a rails model that looks something like this: class Recipe < ActiveRecord::Base
sorry for my english, I have a model named Recipe and Recipe has an
I'm making a recipe-manager (who isn't as their first app?) in Rails, and here
we have model helper (used by several different models) called set_guids that sets self.theguid
I have created a model POCO class called Recipe ; a corresponding RecipeRepository persists
I am building a recipe manager as a first rails app. I have a
I have a Recipe model, which has Ingredients embedded in it, using Mongoid. class
Long term lurker, first time poster here. I have written a class to model

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.