School Years/Teams listing problem


#1

People,

I have tables years and teams and I have the years listing like:

1965
1966
1967
.
.

I want to be able to click on the year and ONLY list teams for that
year. At first I thought the following was working until I started
populating the table with teams for more than one year.

For views/years/list.rhtml:

<% for year in @years %>

<%= link_to year.name, :controller=>"teams", :action => "list", :year_id => "#{year.id}" %>

but it doesn’t matter what year I click on, I get all possible teams . .
I have tried various permutations but can’t see how to do it. My tables
look like (in table years, I have set the id to be the same as the name
eg 1965):

Table “public.years”
id | integer
name | integer

Table “public.teams”
id | integer
name | character varying
year_id | integer

Any help appreciated!

Regards,

Phil.

Philip R.

Pricom Pty Limited (ACN 003 252 275 ABN 91 003 252 275)
GPO Box 3411
Sydney NSW 2001
Australia
Mobile: +61:(0)411-185-652
Fax: +61:(0)2-8221-9599
E-mail: removed_email_address@domain.invalid


#2

On 4/25/06, Philip R. removed_email_address@domain.invalid wrote:

I want to be able to click on the year and ONLY list teams for that
year. At first I thought the following was working until I started
populating the table with teams for more than one year.

but it doesn’t matter what year I click on, I get all possible teams . .

What does the code in your controller for filling @years look like? It
should have a condition to limit by the parameter that has the year
ID.

Regards,

Phil.

Sincerely,

Tom L.
http://AllTom.com/
http://GadgetLife.org/


#3

Tom,

On Mon, 2006-05-01 at 11:48 -0400, Tom L. wrote:

I want to be able to click on the year and ONLY list teams for that
year. At first I thought the following was working until I started
populating the table with teams for more than one year.

but it doesn’t matter what year I click on, I get all possible teams . .

What does the code in your controller for filling @years look like? It
should have a condition to limit by the parameter that has the year
ID.

It is just:

def list
@year_pages, @years = paginate :years, :per_page => 20
@years = Year.find_all
@teams = Team.find_all
end

  • but to begin with, all years should display, it is only after
    clicking on a year that all teams for that year only should then
    display . .

Someone else suggested this is a HABTM situation so I was going to look
at that next . .

Thanks for the response!

Regards,

Phil.

Philip R.

Pricom Pty Limited (ACN 003 252 275 ABN 91 003 252 275)
GPO Box 3411
Sydney NSW 2001
Australia
Mobile: +61:(0)411-185-652
Fax: +61:(0)2-8221-9599
E-mail: removed_email_address@domain.invalid