Something is getting lost here. def create @home = Team.find_by_user_id(current_user.id) for player in @home.players player.update_attribute(:game_id, @game.id) end end def show @players = Player.find_all_by_game_id(params[:id]) end view <%= @players.size %> # mistakenly equals zero Played with the console and everything should be working fine... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You don''t seem to be setting @game in your create method. It''d help if you told us what your error was. Julian. Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) VIDEO #3 out TODAY! http://sensei.zenunit.com/ On 07/04/2008, at 6:21 PM, edberner wrote:> > Something is getting lost here. > def create > @home = Team.find_by_user_id(current_user.id) > > for player in @home.players > player.update_attribute(:game_id, @game.id) > end > end > > def show > @players = Player.find_all_by_game_id(params[:id]) > end > > view > <%= @players.size %> # mistakenly equals zero > > Played with the console and everything should be working fine... > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
def create @game = Game.new(params[:game]) @game.opponent = params[:team][:name] @home = Team.find_by_user_id(current_user.id) @opponent = Team.find_by_name(params[:team][:name]) for player in @home.players player.update_attribute(:game_id, @game.id) end if @game.save flash[:notice] = ''Game was successfully created.'' redirect_to edit_school_team_game_url(School.find_by_user_id(current_user.id), @home, @game) else render :action => "new" end end is my whole create method the error is that the game_id is never actually changed for any of the players. it remains nil On Apr 7, 4:50 am, Julian Leviston <jul...-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> wrote:> You don''t seem to be setting @game in your create method. > > It''d help if you told us what your error was. > > Julian. > > Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) > VIDEO #3 out TODAY!http://sensei.zenunit.com/ > > On 07/04/2008, at 6:21 PM, edberner wrote: > > > > > Something is getting lost here. > > def create > > @home = Team.find_by_user_id(current_user.id) > > > for player in @home.players > > player.update_attribute(:game_id, @game.id) > > end > > end > > > def show > > @players = Player.find_all_by_game_id(params[:id]) > > end > > > view > > <%= @players.size %> # mistakenly equals zero > > > Played with the console and everything should be working fine...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
def edit @game = Game.find(params[:id]) @players = Player.find_all_by_game_id(params[:id]) end On Apr 7, 11:39 am, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> def create > @game = Game.new(params[:game]) > @game.opponent = params[:team][:name] > > @home = Team.find_by_user_id(current_user.id) > @opponent = Team.find_by_name(params[:team][:name]) > > for player in @home.players > player.update_attribute(:game_id, @game.id) > end > > if @game.save > flash[:notice] = ''Game was successfully created.'' > > redirect_to > edit_school_team_game_url(School.find_by_user_id(current_user.id), > @home, @game) > else > render :action => "new" > end > > end > > is my whole create method > the error is that the game_id is never actually changed for any of the > players. it remains nil > > On Apr 7, 4:50 am, Julian Leviston <jul...-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> wrote: > > > You don''t seem to be setting @game in your create method. > > > It''d help if you told us what your error was. > > > Julian. > > > Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) > > VIDEO #3 out TODAY!http://sensei.zenunit.com/ > > > On 07/04/2008, at 6:21 PM, edberner wrote: > > > > Something is getting lost here. > > > def create > > > @home = Team.find_by_user_id(current_user.id) > > > > for player in @home.players > > > player.update_attribute(:game_id, @game.id) > > > end > > > end > > > > def show > > > @players = Player.find_all_by_game_id(params[:id]) > > > end > > > > view > > > <%= @players.size %> # mistakenly equals zero > > > > Played with the console and everything should be working fine...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Am I not describing my problem correctly? On Apr 7, 11:42 am, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> def edit > @game = Game.find(params[:id]) > @players = Player.find_all_by_game_id(params[:id]) > end > > On Apr 7, 11:39 am, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > def create > > @game = Game.new(params[:game]) > > @game.opponent = params[:team][:name] > > > @home = Team.find_by_user_id(current_user.id) > > @opponent = Team.find_by_name(params[:team][:name]) > > > for player in @home.players > > player.update_attribute(:game_id, @game.id) > > end > > > if @game.save > > flash[:notice] = ''Game was successfully created.'' > > > redirect_to > > edit_school_team_game_url(School.find_by_user_id(current_user.id), > > @home, @game) > > else > > render :action => "new" > > end > > > end > > > is my whole create method > > the error is that the game_id is never actually changed for any of the > > players. it remains nil > > > On Apr 7, 4:50 am, Julian Leviston <jul...-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> wrote: > > > > You don''t seem to be setting @game in your create method. > > > > It''d help if you told us what your error was. > > > > Julian. > > > > Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) > > > VIDEO #3 out TODAY!http://sensei.zenunit.com/ > > > > On 07/04/2008, at 6:21 PM, edberner wrote: > > > > > Something is getting lost here. > > > > def create > > > > @home = Team.find_by_user_id(current_user.id) > > > > > for player in @home.players > > > > player.update_attribute(:game_id, @game.id) > > > > end > > > > end > > > > > def show > > > > @players = Player.find_all_by_game_id(params[:id]) > > > > end > > > > > view > > > > <%= @players.size %> # mistakenly equals zero > > > > > Played with the console and everything should be working fine...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
i''m absolutely perplexed... Player Update (0.000416) UPDATE players SET "created_at" ''2008-04-07 12:35:45'', "school_id" = 2, "team_id" = 2, "first" = ''w'', "updated_at" = ''2008-04-07 12:43:38'', "game_id" = NULL, "last" = ''o'' WHERE "id" = 4 Why is it not setting game_id???? On Apr 7, 12:19 pm, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Am I not describing my problem correctly? > > On Apr 7, 11:42 am, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > def edit > > @game = Game.find(params[:id]) > > @players = Player.find_all_by_game_id(params[:id]) > > end > > > On Apr 7, 11:39 am, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > def create > > > @game = Game.new(params[:game]) > > > @game.opponent = params[:team][:name] > > > > @home = Team.find_by_user_id(current_user.id) > > > @opponent = Team.find_by_name(params[:team][:name]) > > > > for player in @home.players > > > player.update_attribute(:game_id, @game.id) > > > end > > > > if @game.save > > > flash[:notice] = ''Game was successfully created.'' > > > > redirect_to > > > edit_school_team_game_url(School.find_by_user_id(current_user.id), > > > @home, @game) > > > else > > > render :action => "new" > > > end > > > > end > > > > is my whole create method > > > the error is that the game_id is never actually changed for any of the > > > players. it remains nil > > > > On Apr 7, 4:50 am, Julian Leviston <jul...-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> wrote: > > > > > You don''t seem to be setting @game in your create method. > > > > > It''d help if you told us what your error was. > > > > > Julian. > > > > > Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) > > > > VIDEO #3 out TODAY!http://sensei.zenunit.com/ > > > > > On 07/04/2008, at 6:21 PM, edberner wrote: > > > > > > Something is getting lost here. > > > > > def create > > > > > @home = Team.find_by_user_id(current_user.id) > > > > > > for player in @home.players > > > > > player.update_attribute(:game_id, @game.id) > > > > > end > > > > > end > > > > > > def show > > > > > @players = Player.find_all_by_game_id(params[:id]) > > > > > end > > > > > > view > > > > > <%= @players.size %> # mistakenly equals zero > > > > > > Played with the console and everything should be working fine...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 7 Apr 2008, at 17:46, edberner wrote:> > i''m absolutely perplexed... > Player Update (0.000416) UPDATE players SET "created_at" > ''2008-04-07 12:35:45'', "school_id" = 2, "team_id" = 2, "first" = ''w'', > "updated_at" = ''2008-04-07 12:43:38'', "game_id" = NULL, "last" = ''o'' > WHERE "id" = 4> > Why is it not setting game_id???? >The game hasn''t been saved and so it doesn''t have an id. Fred> > On Apr 7, 12:19 pm, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Am I not describing my problem correctly? >> >> On Apr 7, 11:42 am, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>> def edit >>> @game = Game.find(params[:id]) >>> @players = Player.find_all_by_game_id(params[:id]) >>> end >> >>> On Apr 7, 11:39 am, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >>>> def create >>>> @game = Game.new(params[:game]) >>>> @game.opponent = params[:team][:name] >> >>>> @home = Team.find_by_user_id(current_user.id) >>>> @opponent = Team.find_by_name(params[:team][:name]) >> >>>> for player in @home.players >>>> player.update_attribute(:game_id, @game.id) >>>> end >> >>>> if @game.save >>>> flash[:notice] = ''Game was successfully created.'' >> >>>> redirect_to >>>> edit_school_team_game_url(School.find_by_user_id(current_user.id), >>>> @home, @game) >>>> else >>>> render :action => "new" >>>> end >> >>>> end >> >>>> is my whole create method >>>> the error is that the game_id is never actually changed for any >>>> of the >>>> players. it remains nil >> >>>> On Apr 7, 4:50 am, Julian Leviston <jul...-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> wrote: >> >>>>> You don''t seem to be setting @game in your create method. >> >>>>> It''d help if you told us what your error was. >> >>>>> Julian. >> >>>>> Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) >>>>> VIDEO #3 out TODAY!http://sensei.zenunit.com/ >> >>>>> On 07/04/2008, at 6:21 PM, edberner wrote: >> >>>>>> Something is getting lost here. >>>>>> def create >>>>>> @home = Team.find_by_user_id(current_user.id) >> >>>>>> for player in @home.players >>>>>> player.update_attribute(:game_id, @game.id) >>>>>> end >>>>>> end >> >>>>>> def show >>>>>> @players = Player.find_all_by_game_id(params[:id]) >>>>>> end >> >>>>>> view >>>>>> <%= @players.size %> # mistakenly equals zero >> >>>>>> Played with the console and everything should be working fine... > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You''re a genius thank you for finding my silly mistake. On Apr 7, 12:57 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 7 Apr 2008, at 17:46, edberner wrote: > > > > > i''m absolutely perplexed... > > Player Update (0.000416) UPDATE players SET "created_at" > > ''2008-04-07 12:35:45'', "school_id" = 2, "team_id" = 2, "first" = ''w'', > > "updated_at" = ''2008-04-07 12:43:38'', "game_id" = NULL, "last" = ''o'' > > WHERE "id" = 4 > > > Why is it not setting game_id???? > > The game hasn''t been saved and so it doesn''t have an id. > > Fred > > > > > On Apr 7, 12:19 pm, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Am I not describing my problem correctly? > > >> On Apr 7, 11:42 am, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>> def edit > >>> @game = Game.find(params[:id]) > >>> @players = Player.find_all_by_game_id(params[:id]) > >>> end > > >>> On Apr 7, 11:39 am, edberner <eber...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>>> def create > >>>> @game = Game.new(params[:game]) > >>>> @game.opponent = params[:team][:name] > > >>>> @home = Team.find_by_user_id(current_user.id) > >>>> @opponent = Team.find_by_name(params[:team][:name]) > > >>>> for player in @home.players > >>>> player.update_attribute(:game_id, @game.id) > >>>> end > > >>>> if @game.save > >>>> flash[:notice] = ''Game was successfully created.'' > > >>>> redirect_to > >>>> edit_school_team_game_url(School.find_by_user_id(current_user.id), > >>>> @home, @game) > >>>> else > >>>> render :action => "new" > >>>> end > > >>>> end > > >>>> is my whole create method > >>>> the error is that the game_id is never actually changed for any > >>>> of the > >>>> players. it remains nil > > >>>> On Apr 7, 4:50 am, Julian Leviston <jul...-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> wrote: > > >>>>> You don''t seem to be setting @game in your create method. > > >>>>> It''d help if you told us what your error was. > > >>>>> Julian. > > >>>>> Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) > >>>>> VIDEO #3 out TODAY!http://sensei.zenunit.com/ > > >>>>> On 07/04/2008, at 6:21 PM, edberner wrote: > > >>>>>> Something is getting lost here. > >>>>>> def create > >>>>>> @home = Team.find_by_user_id(current_user.id) > > >>>>>> for player in @home.players > >>>>>> player.update_attribute(:game_id, @game.id) > >>>>>> end > >>>>>> end > > >>>>>> def show > >>>>>> @players = Player.find_all_by_game_id(params[:id]) > >>>>>> end > > >>>>>> view > >>>>>> <%= @players.size %> # mistakenly equals zero > > >>>>>> Played with the console and everything should be working fine...--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---