I have a single form - depending which link the user clicks to display the form, I want different hidden params to be passed to the record and saved upon submission. Is there a nice way to do this? Thanks in advance!
For instance:
<%= link_to 'General Request', new_request_path %>
<%= link_to 'Project Request', new_request_path %> ### -> set request.project = true
<%= link_to 'Administrative Request', new_request_path %> ### -> set request.admin = true
For your examples, you'd use:
<%= link_to 'Project Request', new_request_path(project: true) %>
which would produce a link like http://127.0.0.1:3000/request?project=true
and
<%= link_to 'Administrative Request', new_request_path(admin: true) %>
which would produce a link like http://127.0.0.1:3000/request?admin=true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With