Every time i go back to my nascent Rails app several more Rails versions have passed. This time moving up to 0.10.1 caused it not to work any more. I just create the whole thing anew and do some copying. Rails sure is moving fast... but i''m not (really) complaining. My nuby question, though, is how (conceptually) to create controllers for, say, the letters A-Z so that (slightly) different code is executed for each directory... e.g. albums/C/ will list all albums beginning with the letter C. I wouldn''t think i''d need to create a method for each letter, but i don''t know a better way. Anyone supply an idea? craig
On Mon, 21 Mar 2005 19:30:29 -0500, craig duncan <craig-duncan-ihVZJaRskl1bRRN4PJnoQQ@public.gmane.org> wrote:> Every time i go back to my nascent Rails app several more Rails versions have passed. > This time moving up to 0.10.1 caused it not to work any more. I just create the > whole thing anew and do some copying. Rails sure is moving fast... but i''m not > (really) complaining. My nuby question, though, is how (conceptually) to create > controllers for, say, the letters A-Z so that (slightly) different code is executed > for each directory... e.g. albums/C/ will list all albums beginning with the letter > C. I wouldn''t think i''d need to create a method for each letter, but i don''t know a > better way. Anyone supply an idea?Create a route like this: map.connect ''albums/:letter'', :controller => ''albums'', :action => ''list'', :letter => /^[a-z]$/ Now in your controller you can access the variable @params[''letter''] and do something with it. (eg, do a find_by_sql for album titles that start with that letter). -- One Guy With A Camera http://rbpark.ath.cx
Rob Park wrote:> On Mon, 21 Mar 2005 19:30:29 -0500, craig duncan > <craig-duncan-ihVZJaRskl1bRRN4PJnoQQ@public.gmane.org> wrote: > >>Every time i go back to my nascent Rails app several more Rails versions have passed. >> This time moving up to 0.10.1 caused it not to work any more. I just create the >>whole thing anew and do some copying. Rails sure is moving fast... but i''m not >>(really) complaining. My nuby question, though, is how (conceptually) to create >>controllers for, say, the letters A-Z so that (slightly) different code is executed >>for each directory... e.g. albums/C/ will list all albums beginning with the letter >>C. I wouldn''t think i''d need to create a method for each letter, but i don''t know a >>better way. Anyone supply an idea? > > > Create a route like this: > > map.connect ''albums/:letter'', :controller => ''albums'', :action => > ''list'', :letter => /^[a-z]$/ > > Now in your controller you can access the variable @params[''letter''] > and do something with it. (eg, do a find_by_sql for album titles that > start with that letter).Thanks much. I don''t know what a route is, in Rails, but i''ll go look for it immediately (like i said, i really haven''t been able to keep up). craig