If you do redirect, you lose all the instance
variables in q2. I would say go directly to list, and
make a function call from there:
def list
q2
#any other list-specific actions
end
that will let the controller access the q2 variables
from the list action.
cheers,
B Gates
Hi again! I am able to create the query string
correctly now for the
conditions. I’d like to use my common list function
to show the
records. So, what I’d like to do is call a set of
different functions
that create the correct search conditions based on
what is entered in
the forms.
But, although I’m able to construct the query in a
controller function
called ‘query1’ - unfortunately this does not work:
def q2
id = params[:id]
qa = ['name like ?']
sid = '%' + params[:name] + '%'
@qp = [sid]
qa << 'test_date >= ?'
@qp << params[:start]
@condition = [qa.join(' and ')] + @qp
params[:condition] = @condition
redirect_to :action => 'list2'
end
I’m confused whether I should use:
redirect_to :action => ‘list2’
or
render :action => ‘list2’
On the other side, list2 picks it up and uses it for
the pagination (if
I put the above code into list2 it works fine)
@condition = params[:condition]
@kx21_result_pages, @kx21_results =
paginate(:kx21_results,
:per_page => 20,
:conditions =>
@condition,
:order_by =>
@sort_order)
How do I pass the conditions array as a parameter to
the redirect?
It does work if I ‘render :action => list2’ into the
function that
creates the query (q2 above) - but, then I must
duplicate the code that
checks and creates the strings for the sort order,
etc… I guess I
could DRY it up?
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around