Hi all, I am teaching myself rails and I can''t figure out why the following code does not work: ''say'' part works, but nothing shows up for ''get_new'' part. Here is my chat_controller.rb file: class ChatController < ApplicationController def index end def say @line = params[:say_so] end def get_new end end --------------------------------------------------------------------------------------------------------------------- Here is my index.rhtml file: <%= form_remote_tag :update => "put_here", :url => {:action => ''say''} %> <%= text_field_tag ''say_so'' %> <p id="put_here"> </p> <%= submit_tag ''Say'' %> <%= end_form_tag %> <%= periodically_call_remote :url => {:action => ''get_new'' }, :update => ''put_there'', :frequency => 2.0 %> <p id="put_there"> </p> ----------------------------------------------------------------------------------------------------------------------- say.rhtml and get_new.rhtml files are simply: <%= @line %> ----------------------------------------------------------------------------------------------------------------------- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 15 Jan 2008, at 00:10, Sy wrote:> > Hi all, > > I am teaching myself rails and I can''t figure out why the following > code does not work: ''say'' part works, but nothing shows up for > ''get_new'' part.Each request gets a separate instance of ChatController, so setting @line to something in the say action has no effect on the value of @line when the get_new action is called. Fred> > Here is my chat_controller.rb file: > > class ChatController < ApplicationController > > def index > end > > def say > @line = params[:say_so] > end > > def get_new > end >> end > > --------------------------------------------------------------------------------------------------------------------- > Here is my index.rhtml file: > > <%= form_remote_tag :update => "put_here", :url => {:action => ''say''} > %> > <%= text_field_tag ''say_so'' %> > <p id="put_here"> </p> > <%= submit_tag ''Say'' %> > <%= end_form_tag %> > > <%= periodically_call_remote :url => {:action => ''get_new'' }, :update > => ''put_there'', :frequency => 2.0 %> > <p id="put_there"> </p> >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks! On Jan 15, 4:07 am, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 15 Jan 2008, at 00:10, Sy wrote: > > > > > Hi all, > > > I am teaching myself rails and I can''t figure out why the following > > code does not work: ''say'' part works, but nothing shows up for > > ''get_new'' part. > > Each request gets a separate instance of ChatController, so setting > @line to something in the say action has no effect on the value of > @line when the get_new action is called. > > Fred > > > > > Here is my chat_controller.rb file: > > > class ChatController < ApplicationController > > > def index > > end > > > def say > > @line = params[:say_so] > > end > > > def get_new > > end > > > end > > > --------------------------------------------------------------------------- ------------------------------------------ > > Here is my index.rhtml file: > > > <%= form_remote_tag :update => "put_here", :url => {:action => ''say''} > > %> > > <%= text_field_tag ''say_so'' %> > > <p id="put_here"> </p> > > <%= submit_tag ''Say'' %> > > <%= end_form_tag %> > > > <%=periodically_call_remote:url => {:action => ''get_new'' }, :update > > => ''put_there'', :frequency => 2.0 %> > > <p id="put_there"> </p>--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---