简体   繁体   中英

Rails remove params from rendered form

i have a form in a page, with submit button. Form contains some inputs. When user press sumbit button, he gets so link:

/top?user_id=67508&country=&state=&city=&mode=0&page=19

How to remove empty params, user should not see it - country, city, state in this example

params.delete :country - don't works

You cannot stop any parameters from being submitted from the client by using ruby code. This could easily be solved through Javascript by listening to the submit event of the form, and attaching a handler to this event which filters the parameters.

See this answer for an example.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM