Last active
April 14, 2025 17:46
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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