multiple form submit buttons for a single form rails 4 -


i'm attempting have form allows me either delete multiple posts based on checked or action. i'm struggling accessing post ids form. if use f.submit tags code works fine. however, when try use bootstrap buttons not work.

below view, has form located inside of bootstrap table , submit buttons on outside of table.

         <%= form_for :pending_forms, html: {method: 'get'} |f| %>              <table class="table">                 <tbody>                     <% if @pending_posts.any? %>                             <% @pending_posts.each |post| %>                                 <tr>                                     <td><%= post.post_name %></td>                                     <td><%= post.created_at %></td>                                     <td><%= check_box_tag 'post_ids[]', post.id %></td>                                 </tr>                             <% end %>                     <% end %>                 </tbody>             </table>             <button type="submit" class="btn btn-danger">remove post</button>             <button type="submit" class="btn btn-primary">go live</button>           <% end %> 

 if params[:commit] == "remove post"    pendingpost.where(id: params[:post_ids]).destroy_all  end  if params[:commit] == "go live"    #do stuff  end    

it best write submit buttons inside form_tag scope.

<%= form_tag %>   <table>     <tbody>        <% if @pending_posts.any? %>           <% @pending_posts.each |post| %>             <tr>                <td><%= post.post_name %></td>                <td><%= post.created_at %></td>                <td><%= check_box_tag 'post_ids[]', post.id %></td>             </tr>           <% end %>        <% end %>     </tbody>   </table>   <button type="submit" class="btn btn-danger">remove post</button>   <button type="submit" class="btn btn-primary">go live</button>   <% end %> 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -