Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass values between controller methods

Is there any way to share an array between controller methods and store it until page reloads or calling method of another controller? Some methods should change the array.

like image 989
Antiarchitect Avatar asked Mar 01 '10 07:03

Antiarchitect


People also ask

How do you pass data between action methods in MVC?

ViewData, ViewBag, and TempData are used to pass data between controller, action, and views. To pass data from the controller to view, either ViewData or ViewBag can be used. To pass data from one controller to another controller, TempData can be used.

How do I pass TempData from controller view?

Passing the data from Controller to View using TempData To pass the strongly typed data from Controller to View using TempData, we have to make a model class then populate its properties with some data and then pass that data to TempData as Value and selecting Key's name is the programmer's choice.


1 Answers

you can use rails cache.

Rails.cache.write("list",[1,2,3])
Rails.cache.read("list")
like image 68
allenwei Avatar answered Sep 29 '22 08:09

allenwei