Have you ever worked with Ajax, memoryStore and sessions in Rails?
I''m trying to pass a value through a session variable to various
methods.
I''m calling the methods with Ajax on a submit button. I do this twice
on a
page. The first time I pass a variable from the page to the controller and
store it in the session and write a log entry. This works fine. When the
second button gets pressed it tries to retrieve the session value previously
stored there. However the session doesn''t contains anything. The
previous
value is gone. I''m not sure what is happening and how to get around
this
problem. Can anyone explain what I''m doing wrong?
I need to use memeoryStore since the object I want to store cannot be
marshalled to PStore.
Thxs, Rob
Here is the page code:
<%= form_remote_tag(:update => "mydiv",
:url => {:action => :ajaxp2}) %>
Enter a number:
<%= text_field_tag(:arg1, @params[:arg1], :size => 5, :maxlength => 5)
%>
<%= submit_tag("Submit number with Ajax") %>
<%= end_form_tag %>
<div id="mydiv">
</div>
<p>
<%= form_remote_tag(:update => "monitor",
:url => {:action => :domonitor}) %>
Start the monitor process:
<%= submit_tag("Start monitor with Ajax") %>
<%= end_form_tag %>
<div id="monitor">
</div>
Here is the controller code:
def ajaxp2
session[:value1] = params[:arg1]
logger.warn("p1=" + params[:arg1])
logger.warn(session[:value1])
render(:layout => false)
end
def domonitor
soap = session[:value1]
logger.warn(soap)
render(:layout => false)
end
--
View this message in context:
http://www.nabble.com/Ajax%2C-MemoryStore-and-sessions-t1189801.html#a3135132
Sent from the RubyOnRails Users forum at Nabble.com.