checkbox - Ruby on Rails, submit_tag with 3 checkboxes -


i need like this in ruby on rails. have code selectes specific files either deleted or analyzed:

<% if @files%>     <%= form_tag what_to_do_files_path, method: :get %> <%= submit_tag "delete selected", :name => 'delete' %> <%= submit_tag "analyse", :name => 'analyse' %>   <% @files.each |file| %>     <% if (arraydb.file=="no") %>         <p><td> <%= check_box_tag "files[]", file.id %></td><%= file.name %></p>             <% else %>            <div class="my_profile_info">          <p><td> <%= check_box_tag "files[]", file.id %></td> <%= file.name %></p>              <td class="info">     <a href="<%=file.info%>" target ="_blank" class= "btn btn-mini btn-info">info</a>       </td>         </div>      <% end %>   <%end%> <%end%>  <%else%> <%end%> 

routes:

resources :files       collection                      :what_to_do             end     end 

controller:

def what_to_do   method=params[:commit]     if method == 'delete selected'      smt     elsif  method == 'analyze'      thing    end end 

what need have options "analyze" button. pictures, info, normalization, scatterplots checkbox. so, select pictures , normalization , klick on "analyse", rthose 2 options proceeded. not quite sure how can wrap checkbox submit_tag.

edit

example
choose option (checkbox)

  • normalization
  • pic
  • scatterplots
  • info

choose files(checkbox):

  • file1
  • file2
  • file3

i'm not 100% sure if understand after, understanding:

you have bunch of files pick checkboxes, need option checkboxes pass additional options analyze action?

just add inside form_tag:

<%= check_box_tag "pictures", true %> <%= check_box_tag "normalization", true %> 

and on.

in controller:

elsif method == "analyze"  if params[:pictures]   picture stuff  if params[:normalization]   normalization stuff 

etc etc etc params[:nameofcheckboxtag] either set value (second option, true in example) if checkbox checked, otherwise won't exist. either way, checked options processed example.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -