Forum: Ruby on Rails Ajax, MemoryStore and sessions

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A43c3b9008fd605098e4baeaa0cc2ce0?d=identicon&s=25 Rob Eyres (Guest)
on 2006-02-26 19:40
(Received via mailing list)
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-sess...
Sent from the RubyOnRails Users forum at Nabble.com.
This topic is locked and can not be replied to.