Created
November 29, 2020 11:18
-
-
Save pedromschmitt/e3f473211197223c90bd6d039c628e21 to your computer and use it in GitHub Desktop.
Ransack examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--Select one Tag from many associations:--> | |
<div > | |
<label class="form-label">Tags</label> | |
<%= f.collection_select(:tags_id_eq, @tags, :id, :title, { include_blank: true}, { class: 'form-control', onchange: "this.form.submit();" }) %> | |
</div> | |
<!-- Check box for all tags --> | |
<div> | |
<label class="form-label">Tags</label> | |
<ul> | |
<% @tags.each do |tag| %> | |
<li > | |
<div class="custom-control custom-checkbox"> | |
<input class="custom-control-input" | |
type="checkbox" | |
id="tag_<%=tag.id%>" | |
name="q[tags_id_eq_any][]" | |
value=<%=tag.id.to_s%> | |
<% if params['q']['tags_id_eq_any'] && (params['q']['tags_id_eq_any'].include? tag.id.to_s) %> | |
checked="checked" | |
<% end %> | |
onchange="this.form.submit();" | |
> | |
<labelfor="tag_<%=tag.id%>"><%= tag.title %></label> | |
</div> | |
</li> | |
<% end %> | |
</ul> | |
</div> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment