Home > Search-Filter-Example

Search-Filter-Example

Search-Filter-Example is a project mainly written in RUBY and JAVASCRIPT, it's free.

simple rails app outlining how to use a filter model to aid in searching

== Rails Search Filter Example

This is a small scaffold app to demonstrate how to use a filter model to help search across multiple objects

This example has a users, shifts and user_shifts tables/ActiveRecord models (but at this point only the shifts is used) and a filter model.

== Where to look app/controllers/shifts_controller.rb

def index
    # this is where we create the filter instance and use it to filter our results

end

app/views/shifts/index.html.erb
    # the div#search_form contains the form we uses to submit search criteria.
    # note that the url is set to shifts/index
    # and the method is set to get


app/models/filter.rb    
    # this is a non-ActiveRecord class -- meaning it is just a basic ruby class
    # you can do fancy stuff here, but I tried to make the sample code straight forward
    # The gist is, this is an object that represents the searchable fields and performs the searching

==

Previous:hbbplayer