{"id":6525,"date":"2019-05-01T07:27:33","date_gmt":"2019-05-01T07:27:33","guid":{"rendered":"https:\/\/www.botreetechnologies.com\/blog\/?p=6525"},"modified":"2026-04-01T12:17:52","modified_gmt":"2026-04-01T06:47:52","slug":"implementing-advanced-search-in-ruby-on-rails-with-ransack","status":"publish","type":"post","link":"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/","title":{"rendered":"Implement Ransack Gem in Ruby on Rails"},"content":{"rendered":"\n<p>\u201cSearching\u201d is the most common feature of most of the web applications irrespective of size, small or enterprise grade. But how do you implement this feature in web applications?<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span style=\"font-weight: 400;\">Searching with Ransack in Ruby on Rails Application<\/span><\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/activerecord-hackery\/ransack\" target=\"_blank\" rel=\"noopener noreferrer\">Ransack<\/a> gem is a very powerful and feature-rich gem used widely by Rails community to implement advanced search capability in a Ruby on Rails application. You can create simple as well as advanced search forms for with this Rails search gem.<\/p>\n\n\n\n<p>Let\u2019s build a small search app using simple and advanced search options for implementing search in Rails.<\/p>\n\n\n\n<p>First of all, add <a href=\"https:\/\/github.com\/activerecord-hackery\/ransack\" target=\"_blank\" rel=\"noopener noreferrer\">Ransack<\/a> gem to your gemfile and bundle.<\/p>\n\n\n\n<p><em>Gemfile<\/em><\/p>\n\n\n\n<p><code>gem 'ransack', github: 'activerecord-hackery\/ransack'<\/code><\/p>\n\n\n\n<p><code>$ bundle<\/code><\/p>\n\n\n\n<p>Ruby on Rails developers can first create a scaffold for Student details which we can use further to explore different search options provided by Ransack.<\/p>\n\n\n\n<p><code>$ rails g scaffold Student name age:integer marks:integer<\/code><\/p>\n\n\n\n<p>After generating Student scaffold you have below code in your student index view<\/p>\n\n\n\n<p><em>In app\/views\/students\/index.html.erb<\/em><\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/GandhiDhaval\/79866e8dc66e408851cf9fa06c30b4bd.js\"><\/script><\/p>\n\n\n\n<p>As we are going for search directly we don\u2019t need a new student link in view so remove below link from index view,<\/p>\n\n\n\n<p>In <em>app\/views\/students\/index.html.erb<\/em> <strong>[Remove below line from index.html]<\/strong><\/p>\n\n\n\n<p><code>&lt;%= link_to 'New Student', new_student_path %&gt;<\/code><\/p>\n\n\n\n<p>To add few student records in database add below lines of code in your seed file<\/p>\n\n\n\n<p>In db\/seeds.rb<\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/GandhiDhaval\/285cc9004ecde4dcf785cb1e25eb4d07.js\"><\/script><\/p>\n\n\n\n<p>To create a database with desire student schema with few records write below command in terminal.<\/p>\n\n\n\n<p><code>$ rails db:setup<\/code><\/p>\n\n\n\n<p>Above command will create a database with scaffold migration and student records.<\/p>\n\n\n\n<p>Ransack provides form helper <code>search_form_for<\/code> which you can think of as an extension to <code>form_for<\/code> with some metaprogramming magic to give you a powerful DSL specifying predicates. When the form generated by <code>search_form_for<\/code> is submitted, the handler(controller) creates Ransack::Search and validates it.<\/p>\n\n\n\n<p>Here we are searching by name in the Student table. So add below code for the search to students\u2019 index view page above the table or elsewhere you want to display searching form in the view.<\/p>\n\n\n\n<p><em>In app\/views\/students\/index.html.erb<\/em><\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/GandhiDhaval\/38008cea2a4be978e4699c274bb9a8a7.js\"><\/script><\/p>\n\n\n\n<p>Here we have name field in our table, then we have to mention it like \u201c<code>name_cont<\/code>\u201d in helper <code>search_form_for<\/code>. Here we used \u201c<code>_cont<\/code>\u201d matcher which means Contains value in \u201c<code>name<\/code>\u201d field. If we did not follow the conventions then ransack will return the full list of data without proper searching.<\/p>\n\n\n\n<p>Here is how our controller will look like.<\/p>\n\n\n\n<p><em>app\/controllers\/students_controller.rb<\/em><\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/GandhiDhaval\/e7de65f820a6974b784bc8943411b724.js\"><\/script><\/p>\n\n\n\n<p>Here, &nbsp;<code>@q<\/code> is a ransack::search object using a parameter which is in <code>params[:q]<\/code>.<\/p>\n\n\n\n<p>And <code>#result<\/code> method of ransack returns an ActiveRecordRelation object with matching result which we can utilize to display in view files.<\/p>\n\n\n\n<p>The above code gives the result of search like below:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"444\" height=\"190\" src=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/result-of-search.png\" alt=\"Searching with Ransack in Ruby on Rails\" class=\"wp-image-13490\" srcset=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/result-of-search.png 444w, https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/result-of-search-300x128.png 300w\" sizes=\"auto, (max-width: 444px) 100vw, 444px\" \/><\/figure>\n\n\n\n<p>Ransack provides different <strong>search matches<\/strong> as below. We can apply any of them based on our requirement.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"453\" height=\"387\" src=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/search-matches1.png\" alt=\"ransack custom sort\" class=\"wp-image-13491\" srcset=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/search-matches1.png 453w, https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/search-matches1-300x256.png 300w\" sizes=\"auto, (max-width: 453px) 100vw, 453px\" \/><\/figure>\n\n\n\n<p>Here is the list of all <a href=\"https:\/\/github.com\/activerecord-hackery\/ransack#user-content-search-matchers\" target=\"_blank\" rel=\"noopener noreferrer\">available<\/a>&nbsp;matches which you can as per the needs.<\/p>\n\n\n\n<p>We can easily integrate sorting functionality as well using <code>#sort_link<\/code>. See below code for that:<\/p>\n\n\n\n<p><em>app\/views\/students\/_student_list.html.erb<\/em><\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/GandhiDhaval\/4e8d067b16b204f313f5084ab6e0570b.js\"><\/script><\/p>\n\n\n\n<p>After adding above sort link it will look like below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"455\" height=\"262\" src=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/sort-link.png\" alt=\"rails ransack\" class=\"wp-image-13492\" srcset=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/sort-link.png 455w, https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/sort-link-300x173.png 300w\" sizes=\"auto, (max-width: 455px) 100vw, 455px\" \/><\/figure>\n\n\n\n<p>Now, let\u2019s implement a bit advanced search tool.<\/p>\n\n\n\n<p>To achieve this, we have to add a few more lines of code in search_form_for file like given below:<\/p>\n\n\n\n<p>app\/views\/students\/index.html.erb<\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/GandhiDhaval\/f5f58f324328f1611c5d2703c5919543.js\"><\/script><\/p>\n\n\n\n<p>For an advanced search, ransack uses nested structures of input fields. It groups all conditions and each of that group has an attribute name and value which is a search value on a specific attribute.<\/p>\n\n\n\n<p>So the above code results in the following view:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"760\" height=\"266\" src=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/code-is-results.png\" alt=\"Searching and Sorting on Rails with Ransack\" class=\"wp-image-13493\" srcset=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/code-is-results.png 760w, https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/code-is-results-300x105.png 300w\" sizes=\"auto, (max-width: 760px) 100vw, 760px\" \/><\/figure>\n\n\n\n<p>The first dropdown contains table attributes. This is the default behavior. The middle one is for predicates for ransack matchers and text field for values to be searched.<\/p>\n\n\n\n<p>Here we can also restrict to few attributes on which we want to give permission for searching. Just configure table fields name on its model file as below to customize it.<\/p>\n\n\n\n<p><em>app\/models\/student.rb<\/em><\/p>\n\n\n\n<p><script src=\"https:\/\/gist.github.com\/GandhiDhaval\/d5b1e375ef8fc2a90fea0af3050e9cb4.js\"><\/script><\/p>\n\n\n\n<p>Here we are allowing to search on name and marks fields only.<\/p>\n\n\n\n<p>That\u2019s it! You can build your complex search forms with complex queries using Ransack easily.<\/p>\n\n\n\n<p>You can access full codebase in <a href=\"https:\/\/github.com\/Dhaval-Gandhi\/ransack_demo\" target=\"_blank\" rel=\"noopener noreferrer\">this git repo<\/a>. I would highly recommend checking <a href=\"https:\/\/github.com\/activerecord-hackery\/ransack\/wiki\" target=\"_blank\" rel=\"noopener noreferrer\">wiki<\/a> for all different search options available. <\/p>\n\n\n\n<p>Hire BoTree for comprehensive Ruby on Rails development services to implement features in your Rails web app.<\/p>\n\n\n\n<p>Happy coding!<\/p>\n\n\n\n<p><strong><a href=\"https:\/\/www.botreetechnologies.com\/contact\">Consulting is free<\/a> &#8211; let us help you grow!<\/strong><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u201cSearching\u201d is the most common feature of most of the&#8230;<\/p>\n","protected":false},"author":42,"featured_media":13487,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73,10],"tags":[],"class_list":["post-6525","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ruby-on-rails","category-technology"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Implement Ransack Gem in Ruby on Rails<\/title>\n<meta name=\"description\" content=\"Ransack Gem is a popular Rails search gem that enables Ruby on Rails developers to add search functionality. Here\u2019s how to implement it.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Implement Ransack Gem in Ruby on Rails\" \/>\n<meta property=\"og:description\" content=\"Ransack Gem is a popular Rails search gem that enables Ruby on Rails developers to add search functionality. Here\u2019s how to implement it.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/\" \/>\n<meta property=\"og:site_name\" content=\"BoTree Technologies\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/BoTreeTechnologies\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-01T07:27:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-01T06:47:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2019\/05\/ruby-on-rails-with-ransack.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Dhaval Gandhi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@BoTreeTech\" \/>\n<meta name=\"twitter:site\" content=\"@BoTreeTech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dhaval Gandhi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/\"},\"author\":{\"name\":\"Dhaval Gandhi\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/bdbf891395269c154a7a2b46cc985954\"},\"headline\":\"Implement Ransack Gem in Ruby on Rails\",\"datePublished\":\"2019-05-01T07:27:33+00:00\",\"dateModified\":\"2026-04-01T06:47:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/\"},\"wordCount\":715,\"commentCount\":10,\"image\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2019\/05\/ruby-on-rails-with-ransack.jpg\",\"articleSection\":[\"Ruby on Rails\",\"Technology\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/\",\"name\":\"Implement Ransack Gem in Ruby on Rails\",\"isPartOf\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2019\/05\/ruby-on-rails-with-ransack.jpg\",\"datePublished\":\"2019-05-01T07:27:33+00:00\",\"dateModified\":\"2026-04-01T06:47:52+00:00\",\"author\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/bdbf891395269c154a7a2b46cc985954\"},\"description\":\"Ransack Gem is a popular Rails search gem that enables Ruby on Rails developers to add search functionality. Here\u2019s how to implement it.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#primaryimage\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2019\/05\/ruby-on-rails-with-ransack.jpg\",\"contentUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2019\/05\/ruby-on-rails-with-ransack.jpg\",\"width\":1920,\"height\":1080,\"caption\":\"Advanced Search in Ruby on Rails with Ransack\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.botreetechnologies.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Implement Ransack Gem in Ruby on Rails\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#website\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/\",\"name\":\"BoTree Technologies\",\"description\":\"Committed to inspire generation.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.botreetechnologies.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/bdbf891395269c154a7a2b46cc985954\",\"name\":\"Dhaval Gandhi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/dhaval-gandhi-150x150.png\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/dhaval-gandhi-150x150.png\",\"contentUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/dhaval-gandhi-150x150.png\",\"caption\":\"Dhaval Gandhi\"},\"description\":\"Dhaval Gandhi is a Ruby on Rails developer. He likes to build new things and provide a safe pair of hands in challenging times. Also, he understands the importance of being interactive and enjoy communicating with others and is always highly enthused about his work and tasks. Apart from coding, he likes to do photography and listen to songs.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Implement Ransack Gem in Ruby on Rails","description":"Ransack Gem is a popular Rails search gem that enables Ruby on Rails developers to add search functionality. Here\u2019s how to implement it.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/","og_locale":"en_US","og_type":"article","og_title":"Implement Ransack Gem in Ruby on Rails","og_description":"Ransack Gem is a popular Rails search gem that enables Ruby on Rails developers to add search functionality. Here\u2019s how to implement it.","og_url":"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/","og_site_name":"BoTree Technologies","article_publisher":"https:\/\/www.facebook.com\/BoTreeTechnologies\/","article_published_time":"2019-05-01T07:27:33+00:00","article_modified_time":"2026-04-01T06:47:52+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2019\/05\/ruby-on-rails-with-ransack.jpg","type":"image\/jpeg"}],"author":"Dhaval Gandhi","twitter_card":"summary_large_image","twitter_creator":"@BoTreeTech","twitter_site":"@BoTreeTech","twitter_misc":{"Written by":"Dhaval Gandhi","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#article","isPartOf":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/"},"author":{"name":"Dhaval Gandhi","@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/bdbf891395269c154a7a2b46cc985954"},"headline":"Implement Ransack Gem in Ruby on Rails","datePublished":"2019-05-01T07:27:33+00:00","dateModified":"2026-04-01T06:47:52+00:00","mainEntityOfPage":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/"},"wordCount":715,"commentCount":10,"image":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#primaryimage"},"thumbnailUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2019\/05\/ruby-on-rails-with-ransack.jpg","articleSection":["Ruby on Rails","Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/","url":"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/","name":"Implement Ransack Gem in Ruby on Rails","isPartOf":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#primaryimage"},"image":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#primaryimage"},"thumbnailUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2019\/05\/ruby-on-rails-with-ransack.jpg","datePublished":"2019-05-01T07:27:33+00:00","dateModified":"2026-04-01T06:47:52+00:00","author":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/bdbf891395269c154a7a2b46cc985954"},"description":"Ransack Gem is a popular Rails search gem that enables Ruby on Rails developers to add search functionality. Here\u2019s how to implement it.","breadcrumb":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#primaryimage","url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2019\/05\/ruby-on-rails-with-ransack.jpg","contentUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2019\/05\/ruby-on-rails-with-ransack.jpg","width":1920,"height":1080,"caption":"Advanced Search in Ruby on Rails with Ransack"},{"@type":"BreadcrumbList","@id":"https:\/\/www.botreetechnologies.com\/blog\/implementing-advanced-search-in-ruby-on-rails-with-ransack\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.botreetechnologies.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Implement Ransack Gem in Ruby on Rails"}]},{"@type":"WebSite","@id":"https:\/\/www.botreetechnologies.com\/blog\/#website","url":"https:\/\/www.botreetechnologies.com\/blog\/","name":"BoTree Technologies","description":"Committed to inspire generation.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.botreetechnologies.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/bdbf891395269c154a7a2b46cc985954","name":"Dhaval Gandhi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/dhaval-gandhi-150x150.png","url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/dhaval-gandhi-150x150.png","contentUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/dhaval-gandhi-150x150.png","caption":"Dhaval Gandhi"},"description":"Dhaval Gandhi is a Ruby on Rails developer. He likes to build new things and provide a safe pair of hands in challenging times. Also, he understands the importance of being interactive and enjoy communicating with others and is always highly enthused about his work and tasks. Apart from coding, he likes to do photography and listen to songs."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/6525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=6525"}],"version-history":[{"count":6,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/6525\/revisions"}],"predecessor-version":[{"id":20644,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/6525\/revisions\/20644"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/media\/13487"}],"wp:attachment":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=6525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=6525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=6525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}