instance variable in controller -> views with RJS?

Hi everyone,

This should be pretty simple... If you have an instance variable in a controller passed to its view, and you have <% form_remote_tag :url => { :action => 'other_action' } do -%> etc <% end %>, can you access the instance variable in the action other_action?

You're not really changing the view...

The idea is that I really need to store a variable and have it go from first action -> view -> second action -> manipulated -> passed back to the view in render :update. If the above is not possible, what is the best way to do this? Sessions?

Thanks. - Shannon

i am new to ruby but i believe you can do it with the local option on partial.

pass it in on the form

<% form_remote_tag :url => {:action => 'other_action', :the_var =>
@the_var } do -%> then in the destination action, set

@the_var = params[:the_var]

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #4 coming soon! http://sensei.zenunit.com/

No, that's not what he meant.

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #4 coming soon! http://sensei.zenunit.com/

Alright. But you can't access it directly from the second action right? The variable I want to pass is a very long array of objects, and I was afraid it wasn't going to be efficient if I passed it through a form (or a session).

Julian Leviston wrote:

Shannon Clipt wrote:

Alright. But you can't access it directly from the second action right? The variable I want to pass is a very long array of objects, and I was afraid it wasn't going to be efficient if I passed it through a form (or a session).

Julian Leviston wrote:

pass it in on the form

<% form_remote_tag :url => {:action => 'other_action', :the_var => @the_var } do -%> then in the destination action, set

@the_var = params[:the_var]

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) VIDEO #4 coming soon! http://sensei.zenunit.com/

When you submit that form it will make a 'new' request back to the server. Unfortunately rails really resets 'per request' -- except for session vars and things you pass back to it.

Shannon Clipt wrote:

by the way, the object i'm passing has sensitive data. should i still pass it through the form?

only if you trust the security of your clients' computers :slight_smile: I suppose if it's sensitive save it to your session [or to a database then reload it]

Shannon Clipt wrote:

by the way, the object i'm passing has sensitive data. should i still pass it through the form?

only if you trust the security of your clients' computers :slight_smile: I suppose if it's sensitive save it to your session [or to a database then reload it]

bearing in mind of course that with the default session store the
session data is on the client's computer.

Fred

Frederick Cheung wrote:

Shannon Clipt wrote:

by the way, the object i'm passing has sensitive data. should i still pass it through the form?

only if you trust the security of your clients' computers :slight_smile: I suppose if it's sensitive save it to your session [or to a database then reload it]

bearing in mind of course that with the default session store the session data is on the client's computer.

And keeping in mind that SSL should be used to encrypt transmitting sensitive information over a hostile network like the internet.

- -- Phillip Gawlowski Twitter: twitter.com/cynicalryan

At the bottom of a good deal of the bravery that appears in the world there lurks a miserable cowardice. Men will face powder and steel because they cannot face public opinion. ~ -- Edwin Hubbel Chapin