How doe I search in multiple models with the select option in Rails?
-
I am using sunspot gem and want to implement a search form like this I have two model articles and books this is my articles model class Article < ActiveRecord::Base searchable do text :title text :content end this my books model class Book < ActiveRecord::Base searchable do text :title text :description end i want to know how to implement the search form like this where user choose what they want to search books or articles
-
Answer:
Did you look at Metasearch(or Ransack) under activerecord-hackery. It provides very nice ways to do searches across models. To throw in something more, Rayn Bates of rails casts has a small screencast about the usage of the same http://railscasts.com/episodes/370-ransack
Vineeth B Sathish at Quora Visit the source
Related Q & A:
- How do I search for text inside a PDF?Best solution by Stack Overflow
- How could I aggregate among multiple collections at once with loop?Best solution by stackoverflow.com
- How do I search ALL of Craigslist without having to search each city?Best solution by Yahoo! Answers
- How do I hook up multiple units to a Sound Bar?Best solution by Yahoo! Answers
- How do I get rid of the Other In Box option?Best solution by eHow old
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.