I tried with statics and that did not work. It is as if rails completely unloads the controller between invocations.
class TransientController < ApplicationController def initialize puts 'initialize called' end def gather puts 'gather' respond_to do |format| format.html # index.html.erb end end def show puts 'show ' TransientData.firstname=(params[:firstname]) TransientData.lastname=(params[:lastname]) respond_to do |format| format.html #show.html.erb end end end class TransientData @@firstname='default1' @@lastname='default2' def self.firstname() @@firstname end def self.lastname() @@lastname end def self.lastname=(name) @@lastname = name end def self.firstname=(name) @@firstname=name end end Cris Shupp wrote: > Hi all, > > I have the following file below which is a controller inteneded to > maintain non persisted data. It has two routes defined by 'gather' and > 'show'. Gather displays a form and show, obviously, shows the non > persisted data. My problem is that initialize is called every time > gather and show are called causing me to lose the data contained in @td. > How do I fix this? > > Thanks, > > Cris > > > class TransientController < ApplicationController > > def initialize > @td = TransientData.new > puts 'initialize called' > end > > def gather > puts 'gather' > respond_to do |format| > format.html # gather.html.erb > end > end > > def show > puts 'show ' > @td.firstname=(params[:firstname]) > @td.lastname=(params[:lastname]) > respond_to do |format| > format.html #show.html.erb > end > end > > end > > class TransientData > > def initialize > @firstname='default1' > @lastname='default2' > end > attr_accessor :firstname, :lastname > end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---