Skip to content

Instantly share code, notes, and snippets.

@sephraim
Last active April 14, 2025 17:46
Show Gist options
  • Save sephraim/163ac17ea0556e38396fb197c6c791fa to your computer and use it in GitHub Desktop.
Save sephraim/163ac17ea0556e38396fb197c6c791fa to your computer and use it in GitHub Desktop.
[Rails button_to / link_to params] Pass query params using link_to or hidden params using button_to
<!-- Pass hidden params to the button_to -->
<%= button_to "Buy Now", stripe_embedded_checkout_path, params: { price_id: price.id }, method: :get, data: { turbo: false } %>
<!-- Pass query params to the link_to -->
<%= link_to "Buy Now", stripe_embedded_checkout_path(price_id: price.id), method: :get, data: { turbo: false } %>
<!-- both methods allow you to access params[:price_id] in the controller -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment