Coder Social home page Coder Social logo

sadiqmmm / ransack_demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from activerecord-hackery/ransack_demo

2.0 0.0 0.0 213 KB

A demo app using Ransack to create advanced search forms.

Home Page: http://ransack-demo.herokuapp.com

JavaScript 3.65% Ruby 76.06% CSS 1.40% HTML 15.26% SCSS 3.36% Procfile 0.27%

ransack_demo's Introduction

Ransack Demo Application

This is a quick demonstration of how you might use Ransack in a Rails 5 application to create an "advanced" search form, with nesting, etc.

The main things you'll want to note are:

  • app/models/user.rb - Demonstration of:
    • using a "ransacker" (a virtual, searchable "column") to allow searching on full names from concatenated first and last names.
    • whitelisting attributes allowed for searching using ransackable_attributes.
    • whitelisting attributes allowed for sorting using ransortable_attributes.
  • app/views/users/ - Search form and various partials used in dynamic form.
  • app/helpers/application_helper.rb - setup_search_form, which creates a Javascript search object with a grouping template, since we can't dynamically create grouping templates in Ruby (groupings can contain other groupings, would end up in infinite recursion). The rest of the methods in here are pretty much the same as the nested field helpers in Ryan Bates' Railscast #197.
  • app/assets/javascripts/search.js - JS to handle addition/removal of fields, as well as nesting fields (adding a grouping from the previously mentioned grouping template)

Let us know if you have any questions, and happy ransacking!

ransack_demo's People

Contributors

jonatack avatar deivid-rodriguez avatar dependabot[bot] avatar scarroll32 avatar flov avatar radar avatar haslinger avatar ernie avatar gregmolnar avatar tibastral avatar

Stargazers

Roman avatar Mohammed Sadiq 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.