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 %> <tr> <td> <%= 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 Rhoades 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: phil@pricom.com.au
On 4/25/06, Philip Rhoades <phil@pricom.com.au> wrote:> 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.> 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 Lieber http://AllTom.com/ http://GadgetLife.org/
Tom, On Mon, 2006-05-01 at 11:48 -0400, Tom Lieber wrote:> On 4/25/06, Philip Rhoades <phil@pricom.com.au> wrote: > > 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. > > > 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 Rhoades 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: phil@pricom.com.au