Hi,
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!