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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:31:10+00:00 2026-05-13T11:31:10+00:00

I am very new to Rails so this will probably seem basic to most

  • 0

I am very new to Rails so this will probably seem basic to most of you. I am having trouble getting instance variables from one of my controller methods to show in my view. I am trying to get the first 10 entries of a MySQL table called Odds to show up in a table on my index view.

Here is my Model:

class Odds < ActiveRecord::Base

# select odds for all games
def self.index_odds
    find(:all, :limit => 10)
end
end

Here is my Controller:

class OddsController < ApplicationController
def index
@index_odds = Odds.index_odds
end
end

Here is my View:

<h1>Odds#index</h1>
<table border = "1">
<tr>
<th>id</th>
<th>matchid</th>
<th>typeid</th>
<th>spread_home</th>
<th>spread_away</th>
<th>spread_home_lay</th>
<th>spread_away_lay</th>
<th>home_total</th>
<th>away_total</th>
<th>total_lay</th>
<th>moneyline_home</th>
<th>moneyline_away</th>
<th>moneyline_lay</th>
<th>hteamid</th>
<th>ateamid</th>
</tr>

<% for odds in @index_odds %>
<tr>
<td><%h odds.id %></td>
<td><%h odds.matchid %></td>
<td><%h odds.typeid %></td>
<td><%h odds.spread_home %></td>
<td><%h odds.spread_away %></td>
<td><%h odds.spread_home_lay %></td>
<td><%h odds.spread_away_lay %></td>
<td><%h odds.home_total %></td>
<td><%h odds.away_total %></td>
<td><%h odds.total_lay %></td>
<td><%h odds.moneyline_home %></td>
<td><%h odds.moneyline_away %></td>
<td><%h odds.moneyline_lay %></td>
<td><%h odds.hteamid %></td>
<td><%h odds.ateamid %></td>
</tr>
<% end %>

</table>

The only thing that is showing up is the table heading. 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-13T11:31:11+00:00Added an answer on May 13, 2026 at 11:31 am

    Your code looks okay so I’m going to guess that somehow @index_odds is empty. Your code looks like it’s doing everything correctly so I would drop a p or even a ruby-debug gem’s debugger command if you’re feeling especially saucy.

    Edit: Crikey, you forgot the = in <%= h

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

Sidebar

Related Questions

I'm new to rails development so this is a very basic question. I'm working
This is probably a very simple question, I apologise - I'm new to rails.
This is probably a very simple question to answer. i am new to Rails
(Disclaimer: I am very new to rails) This plugin looks like it will be
I am absolutely and totally new to rails, so the answer is probably very
i am very new to rails . I am having a table holding all
I am trying to run a Rails application. I am very new to this
I'm very new to Ruby on Rails, so there's probably a simple solution I'm
I'm very new to Rails and web development. I'm generating a bunch of objects
I'm currently very new with rails and quite confused. I am doing a school

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.