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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:43:35+00:00 2026-06-14T13:43:35+00:00

I have two tables: one called styles, which has 5 attributes (plus id and

  • 0

I have two tables: one called styles, which has 5 attributes (plus id and created_at) and another called recommender, which has 6 attributes (plus id and created_at).

Once I have defined the 5 attributes on the Styles table, I want to be able to show an entry from the recommender table that has 5 attributes matching the attributes in the styles table.

I have tried a few combinations of Model.find and Model.where to get it, but nothing seems to work.

Here is the styles_controller.rb

def show
@style = Style.find(params[:id])
bt = @style.bodytype
n = @style.need
t = @style.texture
c = @style.color
st = @style.statement   
@recommender =  Recommender.with_bodytype(params[:bt]).with_need(params[:n]).with_texture(params[:t]).with_color(params[:c]).with_statement(params[:st])
respond_to do |format|
  format.html # show.html.erb
  format.json { render json: @style }
 end
end

The message I get is:
Undefined method `with_bodytype’ for #

So, thanks to @bravenewweb for helping out… But there are still some issues:

I think I figured out the problem, but I am not sure how to fix it.

The production environment has Recommender with all its data (I put it there) and so does development.

Recommender exists now at Heroku, but not with any data. And I am not sure how to put it there.

I think the problem is that the Production db is SQLite, even though it is only supposed to work in development and test. So how do I get the production db to talk to Heroku?

Please help!

  • 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-14T13:43:36+00:00Added an answer on June 14, 2026 at 1:43 pm

    It should be much easier than that, ActiveRecord’s find method will by default return the first record that matches. What you want to do is chain the attribute names with and, then pass the query attributes in using the same order as the method name

    @recommender = Recommender.find_by_bodytype_and_need_and_texture_and_color_and_statement(bt, n, t, c, st)
    

    If you want to find all the records matching those params, you just need to start it with

    @recommender = Recommender.find_all_by_bodytype_and_need_and_texture_and_color_and_statement(bt, n, t, c, st)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables: one called Projects, and another called Documents (projects has many
I have two tables, one called countries and one called country. Countries has both
I have two tables one called permissions and one called roles which are related
I have two tables on my database. One called room and another is called
I have two tables. One of them called conversations has the following data. ConversationID
I have two tables, one called PROJETO (id_projeto, id_tipo_projeto, descr_projeto, versao_projeto) and another called
I have two tables - one called customer_records and another called customer_actions . customer_records
I have two tables, one called Events and one called Documents. Each table has
I have two tables, one contains a list of items which is called watch_list
I have two tables i need to query One called horse which contains the

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.