Re rendering a page with an additional Param

Hello!

From my home page you can choose a tire size your looking for this
takes you to the tire_results page.
now this page is built on what tires are in @tire. So you may be looking
at all the 14" tires I have. But you will be looking at singles, pairs
and sets. I would like my customers to be able to narrow down what there
looking for like just find all the set of 4’s or all the pairs.

From the home page a :id gets past to tire_results page… bringing back
all those tires… how can I reuse this same page to render the :id
tires and narrow it down to were t.qty =='s 2 or 1 or what ever.

You can just pass it into the view as a hidden param.

Chris H. wrote in post #974783:

You can just pass it into the view as a hidden param.

like a session variable or some thing?

Well I was thinking that maybe I could build a route that went
controller/action/id/qty
So if :qty was absent it would use the general array of tires with that
:id param and if :qty was present it would then delete all elements that
didn’t meet the qty sent.

Currently the @tires array gets built on were size equals :id. I’m not
sure how to say if :qty != nil{ delete_if( |t|
t.qty != :qty}

<%= hidden_field_tag %>

On Jan 14, 11:36pm, Cameron V. [email protected] wrote:

Chris H. wrote in post #974783:

You can just pass it into the view as a hidden param.

like a session variable or some thing?

I’d avoid session variables.

Well I was thinking that maybe I could build a route that went
controller/action/id/qty
So if :qty was absent it would use the general array of tires with that
:id param and if :qty was present it would then delete all elements that
didnt meet the qty sent.

That is a nicer way of looking at things. It also means (unlike using
a hidden form parameter) that people can link to that precise page,
bookmark it etc.

Currently the @tires array gets built on were size equals :id. Im not
sure how to say if :qty != nil{ delete_if( |t|
t.qty != :qty}

That’s pretty much exactly what you’d do (or you might want to add the
condition on qty into what fetches tries from the database)

Fred

Frederick C. wrote in post #975249:

That’s pretty much exactly what you’d do (or you might want to add the
condition on qty into what fetches tries from the database)

Fred

Thanks for letting me know I was on the right track.