# Passing object between actions

**URL:** <https://www.ruby-forum.com/t/passing-object-between-actions/132966>\
**Category:** Rails\
**Created:** [March 26, 2008, 9:03am UTC](https://www.ruby-forum.com/t/passing-object-between-actions/132966 "2008-03-26T09:03:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [March 26, 2008, 9:03am UTC](https://www.ruby-forum.com/t/passing-object-between-actions/132966/1 "2008-03-26T09:03:46Z")

</div>

Hi  
I have

\<%= link\_to\_remote “Associate Knowledgebase”,  
:update =\> “show\_sd\_knowledgebase”,  
:url =\> { :controller =\>  
‘service\_desk’,:action =\> :search\_knowledge\_base\_ui, :id =\> @sd\_ticket }  
%\>

And this page is completely inside the div show\_sd\_knowledgebase and  
contains @sd\_knowledge\_bases which is the result obtained from  
Sd\_knowledgebases table find.I need to pass this array to action  
search\_knowledge\_base\_ui This is to avoid finding the table again and  
again.How can I do that?

Thanks in advance  
Sijo

---

<div class="post-metadata">

**Author:** ![sijo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/da6949/32.png) [@sijo](https://www.ruby-forum.com/u/sijo)\
**Post date:** [March 26, 2008, 9:42am UTC](https://www.ruby-forum.com/t/passing-object-between-actions/132966/2 "2008-03-26T09:42:20Z")

</div>

Sijo Kg wrote:

> And this page is completely inside the div show\_sd\_knowledgebase and  
> contains @sd\_knowledge\_bases which is the result obtained from  
> Sd\_knowledgebases table find.I need to pass this array to action  
> search\_knowledge\_base\_ui This is to avoid finding the table again and  
> again.How can I do that?

It is customary to hold _small_ pieces of data in the session. The  
controller action adds something to the session before rendering the  
view and the next action reads the data.

I say _small_ because it is highly unwise to preserve large or complex  
data (such as models) like this. There is an excellent RailsCast on the  
subject:

> **[\#13 Dangers of Model in Session - RailsCasts](http://railscasts.com/episodes/13-dangers-of-model-in-session)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

You can also add data into the link\_to\_remote call using :with or as  
parameters to the URL in the :url option. Again, this is not considered  
best practice for complex data. Remember that if the data comes from  
the database, it could change before the user selects the link making  
the cached information out of date and hence invalid…
