Rails 4 - Passing Params via link_to? -


i have single form - depending link user clicks display form, want different hidden params passed record , saved upon submission. there nice way this? 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 examples, you'd use:

<%= link_to 'project request', new_request_path(project: true) %> 

which produce link http://127.0.0.1:3000/request?project=true

and

<%= link_to 'administrative request', new_request_path(admin: true) %> 

which produce link http://127.0.0.1:3000/request?admin=true


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -