GithubHelp home page GithubHelp logo

aliirz / demo_app_for_rails_simple_search Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yzhanginwa/demo_app_for_rails_simple_search

0.0 3.0 0.0 175 KB

Rails 3 application to demo how to use the rails_simple_search

demo_app_for_rails_simple_search's Introduction

This is a rails application. Its purpose is to demo the simplicity and power of gem rails-simple-search.

You can download it and run "bundle; rails s" immediately. It's tested under Ruby 1.9.3-p194 and Rails 3.2.6.

In thie demo, I tried to search for a user by part of her name, her post titles, her comments, her address, her city, her state and so on.

The following is the code related to the search:

1. In file "Gemfile"

  ...
  gem 'rails-simple-search', "~> 0.9.3"
  ...

2. In file "app/model"Search"

  class Search < RailsSimpleSearch::Base
  end

3. In file "config/route.rb"
  ...
  match '/users/index', :controller => 'users', :action => "index"
  ...

3. In file "app/controllers/users_controllers"

  ...
  @search = Search.new(:user, params[:search], :per_page => 2)
  @search.order = 'last_name'
  @users = @search.run
  ...
 
4. In file "app/views/users/index.html.erb"
  ...
  <%= form_for @search, :url => "/users/index" do |f| %>
    <%= f.label "First Name" %>
    <%= f.text_field 'first_name' %>
    <br/>
    <%= f.label "Last Name" %>
    <%= f.text_field 'last_name' %>
    <br/>
    <%= f.label "Address1" %>
    <%= f.text_field 'address.address1' %>
    <br/>
    <%= f.label "City" %>
    <%= f.text_field 'address.city' %>
    <br/>
    <%= f.label "Post title" %>
    <%= f.text_field 'posts.title' %>
    <br/>
    <%= f.label "Post body" %>
    <%= f.text_field 'posts.body' %>
    <br/>
    <%= f.label "Comment" %>
    <%= f.text_field 'comments.body' %>
    <br/>
    <%= f.submit "search" %>
  <% end %>
  ...


For more info about rails-simple-search, please see "https://github.com/yzhanginwa/rails-simple-search".

demo_app_for_rails_simple_search's People

Contributors

yzhanginwa avatar

Watchers

Ali Raza avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.