How to pass data across the different controllers


#1

I have made three scaffold generated controllers in my project by
following three commands

ruby script/generate scaffold amain a:integer
ruby script/generate scaffold bmain b:integer
ruby script/generate scaffold cmain c:integer

I want to take three different inputs( a,b,c) on three different pages
and then on the third page once a user clicks the button “Calculate” a
value based on following equation has to be generated.

value = a + bx1 + cx2

here,
x1 is set on the page where input “a” is set
and x2 is set on the page where input “b” is set

x1 and x2 are virtual attributes and hence do not exist in any of the
data models. Value of these coefficients is not constant and in fact
depends on several dynamic factor such as the date and time when a/b
was set.

I want to know how to pass on the values of “x1” and “x2” from one
controller to another. These attributes are not the part of model of
“a” or model of “b”. I can not keep them in models.

Thanks
vipin


#2

You can always pass the values as hidden fields… your data isn’t going
directly from controller to controller. There are views in between, so
you need a way to ship the data via the views. If you don’t want to see
the values on the pages, you can use hidden fields to pass along the
data.


#3

On May 20, 11:36 pm, Ar Chron removed_email_address@domain.invalid
wrote:

You can always pass the values as hidden fields… your data isn’t going
directly from controller to controller. There are views in between, so
you need a way to ship the data via the views. If you don’t want to see
the values on the pages, you can use hidden fields to pass along the
data.

Posted viahttp://www.ruby-forum.com/.

you mean to say in view there should be some fields which will be set
in controller but will be invisible to the user.
Then in this case, will the values be accessed through param[] table.
Can you please give a small example or some pointer to study about
this topic. if possible

vipin