sam roberts
sam roberts

Reputation: 217

page inbetween search results and results

So i have this page called ticket amount which has a bunch of buttons on it.

Wha im wanting is for the user to click the button on the row of the search results and be taken to that page. The user will then click on the amount of tickets they want and be taken to the page that matches the id from the from the row the button was on.

Basically at the moment its going

Search results >>>>> results

And i want

Search results >>>>> ticket amount >>>>> results

I've currently got the first one set up like this

<%= link_to 'Compare', event_path(event.id), class: "btn btn-info" %>

How would i go about making it different? Basically i'm wanting to use the amount of tickets the user selects in the view. So probably best to change the url from this

/events/idnumber

to

events/idnumber/tickets_required=4

Any ideas how to do this?

At the moment the ticket_amount.html only has basic bootstrap buttons inside

Upvotes: 0

Views: 34

Answers (1)

svelandiag
svelandiag

Reputation: 4320

What you need to do is to send the params in a redirect_to.

What I would do is a small form for let the user select the tickets_required, the form will point to an action in the controller, within that action I would add a redirect to the search results url sending the param:

#Within your controller action once the user selects the tickets_required
redirect_to event_path(event, tickets_required: params[:tickets_required])

Redirect to the search results url or event_path or whatever, and send the tickets_required param in the url using the param[:ticket_required] coming from the form submission

Take a look to this thread that will guide you about how to send the params in the redirect_to

Upvotes: 1

Related Questions