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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:35:35+00:00 2026-05-26T04:35:35+00:00

For some reason the view is blank even though there is data in the

  • 0

For some reason the view is blank even though there is data in the database.In the log shows sql statement selecting the tables but i dont really understand it,Can anybody help me ,what is going on here?Thanks in advance

controller

  @city = City.find(session[:city_id])
  @store_deals=StoreDeal.where("stores.city_id = ?", session[:city_id]).includes(:deal,  :store => [:city])

view

   <% @store_deals.each do |store_deal| %>
   <%= store_deal.deal.item_name %>
   <%= store_deal.store.store_name %>
   <%end%>

In the log

      SQL (0.3ms)  SELECT "store_deals"."id" AS t0_r0, "store_deals"."store_id" AS    t0_r1,    
     "store_deals"."deal_id" AS t0_r2, "store_deals"."created_at" AS t0_r3,   "store_deals". 
     "updated_at" AS t0_r4, "store_deals"."store_name" AS t0_r5, 
     "store_deals". "address" AS t0_r6, "deals"."id" AS t1_r0, "deals"."size" AS t1_r1,  "deals"."item_name" AS t1_r2, 
    "deals"."brand" AS t1_r3, "deals"."stars" AS t1_r4,  "deals"."created_at" AS t1_r5, "deals"."updated_at" AS t1_r6, "deals"."city_id" AS t1_r7, 
     "deals"."category_id" AS t1_r8, "deals"."price" AS t1_r9, "stores"."id" AS t2_r0, "stores"."store_name" AS t2_r1, "stores"."created_at" AS t2_r2, "stores".
     "updated_at" AS t2_r3, "stores"."address" AS t2_r4, "stores"."city_id" AS t2_r5, "cities"."id" AS t3_r0, "cities"."name" AS t3_r1, "cities".
    "created_at" AS t3_r2, "cities"."updated_at" AS t3_r3  FROM "store_deals" LEFT  OUTER JOIN "deals" ON "deals"."id" = "store_deals"."deal_id" LEFT 
     OUTER JOIN "stores" ON "stores"."id" = "store_deals"."store_id" LEFT OUTER JOIN  "cities" ON "cities"."id" = "stores"."city_id" WHERE (stores.city_id = 2)

Models

  class City < ActiveRecord::Base
  has_many :stores
  has_many :deals 
     end

    class Deal < ActiveRecord::Base
    belongs_to :city
    has_many :stores ,:through =>:store_deals
    has_many :store_deals
     end

  class StoreDeal < ActiveRecord::Base
  belongs_to :store
  belongs_to :deal
  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-05-26T04:35:36+00:00Added an answer on May 26, 2026 at 4:35 am

    That is the query that corresponds to your @store_deals = StoreDeal.where ... line. When you use includes Rails uses column aliases (e.g. AS t1_r5) to keep track of which columns in the results belong to which object when it creates objects from the results.

    It’s likely your view is blank because @store_deals is empty, i.e. the query returned no rows. Have you tried inspecting it to see if it contains what you expect it to?

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

Sidebar

Related Questions

Where can I view Tomcat log files in Eclipse? For some reason my Tomcat
For some reason I never see this done. Is there a reason why not?
For some reason, when I try to install SQL Server 2008 Express , I
When I run my app, for some reason the view is pushed up too
For some reason on the iphone, my footer doesn't stretch across the screen, even
I have a view that for some reason displays the memory location of the
I have multiple views all work fine but for some reason a view does
For some reason the rendering of a view is failing on the production server,
For some reason the size if the window always stays the same size even
For some reason when I attempt to make a request to an Ajax.net web

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.