i would appreciate if someone could help me on ruby on rails. can i pass a params[:something] onto a controller?
in my index view i have
<button value="1" name="most_recent" type="submit" class="btn" data-toggle="button">Most Recent</button>
<button value="1" name="score" type="submit" class="btn" data-toggle="button">Score</button>
essentially if a button is pressed, the value goes into my index controller and i can receive it by doing
params[:score]
to see if the score button was pressed. however, also on my index template i have
<%= form_tag search_photos_path, :method => 'get' do %>
<p>
<%= text_field_tag :search, params[:search],
:class => "input-medium search-query expand" %>
<%= submit_tag 'Search', :name => nil, :class => "btn" %>
</p>
<% end %>
when a user clicks search, it goes to my search action. is there a way to send what params[:score] is? if it has been clicked, i want to be able to know it has been clicked. i tried doing params[:search] in my search action, but it returns nil even though i clicked on the search button.
thank you
在模板中的表单内添加隐藏的输入字段,其值为
params[:score]
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.