简体   繁体   中英

Rails: How to send parameter from View to Controller

I want to click a heading and then sort the elements below it. So I have added link_to like this:

%th= link_to "Title"

after this I need to add parameter to send to my controller to sort the list. How do I add parameters? say the list needs to be sorted by "title" of the object.

And which function in my controller will receive the parameter?

I am a newbie so having trouble n tracing the data flow.

link_to "Search Sort", index_path(:sort => "asc", :column => "title")
#=> <a href="/sort?sort=true&amp;column=test">Search Sort</a>

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