README.rdoc in simple-search-0.10.3 vs README.rdoc in simple-search-0.11.0

- old
+ new

@@ -11,58 +11,90 @@ In your Gemfile: gem "simple-search" # Last officially released gem +In your config/environment.rb + + require 'simple_search' + In your controller: def index - @posts = Post.simplesearch(params) - # or, @posts = Post.simplesearch(params[:ss]) # when group options to "ss" - # or, @posts = Post.simplesearch(:id_gt=>1,:id_lt=>3) + @posts = Post.select('posts.*, comments.id as comment_id, comments.body as comment').joins(:comments) + @posts = @posts.simplesearch(params) + render :index end In your view: - <%= form_tag('/posts') do -%> - <%= text_field_tag 'id_gt' %> - <%= text_field_tag 'id_lt' %> - ..... - <%= submit_tag %> + <%= form_tag('/posts', :method=>:GET) do -%> + ID &gt; <%= text_field_tag 'id_gt', params[:id_gt] %> <br/> + Subject contains <%= text_field_tag 'subject_ct', params[:subject_ct] %> <br/> + <%= submit_tag "Search" %> <% end -%> - <%=order_link(:id, "Order by ID" )%> + <style> + #pages a {border:1px solid grey; display:inline-block; min-width:13px; text-align:center; text-decoration: none} + #pages a:first-child, #pages a:last-child {background-color:grey} + #pages a.current {color:white; background-color:#333} + </style> + <div id="pages"> + Pages : <%=raw page_urls(@posts).join(" ") %> + </div> - <%=page_urls(@posts)%> + <table> + <tr> + <th><%=order_link(:id)%></th> + <th><%=order_link(:subject)%></th> + <th><%=order_link(:body)%></th> + <th><%=order_link(:comment_id)%></th> + <th><%=order_link(:comment)%></th> + </tr> + <% @posts.each do |post| %> + <tr> + <td><%=h post.id %></td> + <td><%=h post.subject %></td> + <td><%=h post.body %></td> + <td><%=h post.comment_id %></td> + <td><%=h post.comment %></td> + </tr> + <% end %> + </table> + === Search postfixes * _eq, equal to, = * _gt, greater than, > * _lt, less than, < * _le, less or equal to, <= * _ge, greater or equal to, <= * _in, includes, IN i.e., &id_in=1,2,3 -* _bt(_between), between, BETWEEN +* _bt (alias of _between), between, BETWEEN i.e., &id_between=1,3 -* _sw(_startswith), starts with, LIKE 'key%' ( -* _ew(_endsswith), ends with, LIKE '%key' -* _ct(_contains,_like), contains, LIKE '%key%' -* _nc(_notcontains,_notlike), not contains, NOT LIKE '%key%' +* _sw (alias of _startswith), starts with, LIKE 'key%' ( +* _ew (alias of _endsswith), ends with, LIKE '%key' +* _ct (alias of _contains,_like), contains, LIKE '%key%' +* _nc (alias of _notcontains,_notlike), not contains, NOT LIKE '%key%' * _is, IS i.e., &id_is=null -* _it(_isnot), IS NOT +* _it (alias of _isnot), IS NOT === Sorting your result * order_by i.e., &order_by=id+asc === Paging * page , page number i.e. &page=1 * page_by, number of rows in a page i.e. &page_by=10 + +=== Grouping +* group_by, column to group + i.e. &group_by=posts.id == Contributing to simple-search * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet. * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.