How to pass a value from one action to another?

Dear group,

What are the most elegant ways in Rails to pass the VARIABLE’s value:

  • from action A
  • to action B?

Until now, I’ve been doing this like this (but I’m sure there are other

  1. In action A: redirect_to :action => ‘B’, :id => VARIABLE
  2. In action B: variable = params[:id]


  1. In action A: display a form (form_for :myForm") with a hidden field +
    pass the hidden field a value
  2. In action B: value = params[:myForm][:myHiddenField]

What are the most elegant for passing values in the most direct way?
Is it possible to easily pass values that are not visible to the user?

Thanks a lot!

Sorry, me stupid…

-> You pass the value to the session and retrieve it from the session as
soon as needed…

In case there’s something even better, you’re still welcome!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs