New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

simple-search

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-search

  • 0.13.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= SimpleSearch

SimpleSearch privides search methods for your ActiveRecord models, by providing methods that allow you to search, group, and order. Main goal is to simplify all search related operations from url.

  • Searching
  • Paging
  • Grouping
  • Ordering

== Getting Started

In your Gemfile:

gem "simple-search" # Last officially released gem

In your controller:

def index @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', :method=>:GET) do -%> ID > <%= text_field_tag 'id_gt', params[:id_gt] %>
Subject contains <%= text_field_tag 'subject_ct', params[:subject_ct] %>
<%= submit_tag "Search" %> <% end -%>

#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}
Pages : <%=raw page_urls(@posts, :num_pages=>5).join(" ") %>
<% @posts.each do |post| %> <% end %>
<%=order_link(:id)%><%=order_link(:subject)%><%=order_link(:body)%><%=order_link(:comment_id)%><%=order_link(:comment)%>
<%=h post.id %><%=h post.subject %><%=h post.body %><%=h post.comment_id %><%=h post.comment %>

=== 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 (alias of _between), between, BETWEEN i.e., &id_between=1,3
  • _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 (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.
  • Fork the project.
  • Start a feature/bugfix branch.
  • Commit and push until you are happy with your contribution.
  • Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

== Copyright

Copyright (c) 2012 Allen Kim. See LICENSE.txt for further details.

FAQs

Package last updated on 27 Mar 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc