I have a helper file with 2 defs in it: def team_array @teams = Team.find_all @team_array = [["Select Team",""]] + @teams.map {|u| [u.teamname , u.id]} end def sw_array @swvers = SwVersion.recent_names @sw_array = [["Select SW Version",""]] + @swvers.map {|u| [u.swver_name , u.swver_name]} end These are creating lists to be used in selection boxes on the html forms I am using. The interesting part is that the team_array def works as expected, however the sw_array does not. Being a newbie to RoR I can''t seem to figure out what the difference is. The only thing I can think of is that Team has a relationship to this class while SwVersion does not. If that is the problem how can I fix it? -Michael
On Jun 24, 2005, at 11:00 AM, Michael King wrote:> I have a helper file with 2 defs in it: > def team_array > @teams = Team.find_all > @team_array = [["Select Team",""]] + @teams.map {|u| > [u.teamname , u.id]} > end > > def sw_array > @swvers = SwVersion.recent_names > @sw_array = [["Select SW Version",""]] + @swvers.map {|u| > [u.swver_name , u.swver_name]} > end > > -Michael >Hey Michael- I think that the second method doesn''t work because you are not using a finder. Maybe this will work:> def sw_array@swvers = SwVersion.find_all.recent_names> @sw_array = [["Select SW Version",""]] + @swvers.map {|u| > [u.swver_name , u.swver_name]} > end-Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org 509-577-7732
Ok, I''ll admit I am slightly confused, in my model/sw_version.rb I have: def self.recent_names find_by_sql("select swver_name, modified from ....(huge sql call)") end I am guessing that this is another detail that has eluded my grasp? - Michael On 6/24/05, Ezra Zygmuntowicz <ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org> wrote:> > On Jun 24, 2005, at 11:00 AM, Michael King wrote: > > > I have a helper file with 2 defs in it: > > def team_array > > @teams = Team.find_all > > @team_array = [["Select Team",""]] + @teams.map {|u| > > [u.teamname , u.id]} > > end > > > > def sw_array > > @swvers = SwVersion.recent_names > > @sw_array = [["Select SW Version",""]] + @swvers.map {|u| > > [u.swver_name , u.swver_name]} > > end > > > > -Michael > > > > Hey Michael- > I think that the second method doesn''t work because you are not > using a finder. Maybe this will work: > > > def sw_array > @swvers = SwVersion.find_all.recent_names > > @sw_array = [["Select SW Version",""]] + @swvers.map {|u| > > [u.swver_name , u.swver_name]} > > end > > > -Ezra Zygmuntowicz > WebMaster > Yakima Herald-Republic Newspaper > ezra-gdxLOakOTQ9oetBuM9ipNAC/G2K4zDHf@public.gmane.org > 509-577-7732 > >
How exactly does it not work as expected? Michael King wrote:>I have a helper file with 2 defs in it: >def team_array > @teams = Team.find_all > @team_array = [["Select Team",""]] + @teams.map {|u| [u.teamname , u.id]} >end > >def sw_array > @swvers = SwVersion.recent_names > @sw_array = [["Select SW Version",""]] + @swvers.map {|u| >[u.swver_name , u.swver_name]} >end > >These are creating lists to be used in selection boxes on the html >forms I am using. The interesting part is that the team_array def >works as expected, however the sw_array does not. > >Being a newbie to RoR I can''t seem to figure out what the difference >is. The only thing I can think of is that Team has a relationship to >this class while SwVersion does not. If that is the problem how can I >fix it? > >-Michael >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails