# Loading libraries and passing objects between actions

**URL:** <https://www.ruby-forum.com/t/loading-libraries-and-passing-objects-between-actions/136241>\
**Category:** Rails\
**Created:** [April 30, 2008, 1:48am UTC](https://www.ruby-forum.com/t/loading-libraries-and-passing-objects-between-actions/136241 "2008-04-30T01:48:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![brownerthanu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@brownerthanu](https://www.ruby-forum.com/u/brownerthanu)\
**Post date:** [April 30, 2008, 1:48am UTC](https://www.ruby-forum.com/t/loading-libraries-and-passing-objects-between-actions/136241/1 "2008-04-30T01:48:32Z")

</div>

hello all,

i’m starting on a rails app that will hopefully make machine maintenance  
much easier at my work. i have a few general questions about what  
approach to take in the design.

for each machine the app maintains, it loads a networking library,  
connects to the machine and returns an object of that machine. commands  
to that machine are run via instance methods of the object. different  
machines use different versions of the networking library.

once i’ve created the machine object, how do i pass it back and forth  
between actions? the rails documentation is very jumbled when it comes  
to this.

-reid

---

<div class="post-metadata">

**Author:** ![brownerthanu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@brownerthanu](https://www.ruby-forum.com/u/brownerthanu)\
**Post date:** [April 30, 2008, 5:54am UTC](https://www.ruby-forum.com/t/loading-libraries-and-passing-objects-between-actions/136241/2 "2008-04-30T05:54:48Z")

</div>

save it as a global ?

On Tue, Apr 29, 2008 at 5:48 PM, Reid O.

---

<div class="post-metadata">

**Author:** ![brownerthanu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@brownerthanu](https://www.ruby-forum.com/u/brownerthanu)\
**Post date:** [April 30, 2008, 7:15pm UTC](https://www.ruby-forum.com/t/loading-libraries-and-passing-objects-between-actions/136241/3 "2008-04-30T19:15:01Z")

</div>

i’d like to try to avoid having too many global variables. isn’t there  
a way to pass objects from action to action?

Roger P. wrote:

> save it as a global ?
> 
> On Tue, Apr 29, 2008 at 5:48 PM, Reid O.

---

<div class="post-metadata">

**Author:** ![brownerthanu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@brownerthanu](https://www.ruby-forum.com/u/brownerthanu)\
**Post date:** [April 30, 2008, 8:30pm UTC](https://www.ruby-forum.com/t/loading-libraries-and-passing-objects-between-actions/136241/4 "2008-04-30T20:30:37Z")

</div>

On 30 Apr 2008, at 18:15, browner than u wrote:

> i’d like to try to avoid having too many global variables. isn’t  
> there  
> a way to pass objects from action to action?

global variables are a horrendously bad idea. If you want something to  
persist across actions use the database, the session, memcached etc…  
Fred

---

<div class="post-metadata">

**Author:** ![brownerthanu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@brownerthanu](https://www.ruby-forum.com/u/brownerthanu)\
**Post date:** [April 30, 2008, 9:24pm UTC](https://www.ruby-forum.com/t/loading-libraries-and-passing-objects-between-actions/136241/5 "2008-04-30T21:24:45Z")

</div>

Frederick C. wrote:

> On 30 Apr 2008, at 18:15, browner than u wrote:
> 
> > i’d like to try to avoid having too many global variables. isn’t  
> > there  
> > a way to pass objects from action to action?
> 
> global variables are a horrendously bad idea. If you want something to  
> persist across actions use the database, the session, memcached etc…  
> Fred

all i want to do is pass a “computer” object (specific to the networking  
library i’m using) from action to action, just as i would in functional  
programming. is this not possible?

---

<div class="post-metadata">

**Author:** ![brownerthanu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@brownerthanu](https://www.ruby-forum.com/u/brownerthanu)\
**Post date:** [April 30, 2008, 9:31pm UTC](https://www.ruby-forum.com/t/loading-libraries-and-passing-objects-between-actions/136241/6 "2008-04-30T21:31:04Z")

</div>

On 30 Apr 2008, at 20:24, browner than u wrote:

> > to  
> > persist across actions use the database, the session, memcached  
> > etc…  
> > Fred
> 
> all i want to do is pass a “computer” object (specific to the  
> networking  
> library i’m using) from action to action, just as i would in  
> functional  
> programming. is this not possible?

It is possible, by storing it in one of those places I named.  
Maintaining large amounts of state across actions is not something web  
apps in general are good at.

Fred

---

<div class="post-metadata">

**Author:** ![brownerthanu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e5b9ba/32.png) [@brownerthanu](https://www.ruby-forum.com/u/brownerthanu)\
**Post date:** [April 30, 2008, 9:42pm UTC](https://www.ruby-forum.com/t/loading-libraries-and-passing-objects-between-actions/136241/7 "2008-04-30T21:42:14Z")

</div>

Frederick C. wrote:

> > programming. is this not possible?
> 
> It is possible, by storing it in one of those places I named.  
> Maintaining large amounts of state across actions is not something web  
> apps in general are good at.
> 
> Fred

great. this is good info. thanks!
