Reputation: 10072
I have a multi stage form I'm trying to process. One of the later stages needs to use data set by a previous stage. I had thought that by setting the data I need in an instance variable, e.g.
@gateway = importer.get_gateway
I could then access it in a different controller method of the same controller class, e.g.
Rails.logger.info "populate_devices : gateway is #{@gateway}"
However in the logs @gateway
is nil
in this next step of the form submission. Should it be working, or is this not the correct way to pass data from one controller method to another in the same controller class? @gateway
is definitely being set to not nil
in the previous step as I display some of it's fields on the UI and have logged it.
Upvotes: 1
Views: 1482
Reputation: 4315
I think you should store it in session, because Rails is a stateless technology. There are limitations in size, but only if you choose to use a cookie session store (up to 4k).
If you decide to use the ActiveRecord session store or memcached store, there are no limits. They are easy to implement and fast.
Upvotes: 4