MetaWhere provides a way to do complex find conditions without SQL in Active Record. MetaSearch makes it easy to create search forms with many find options.
Its unfortunate that Ben Johnson has dropped off the face of the Earth with Searchlogic and Authlogic. I'd love to see these gems running on Rails 3 but at least Meta Search and Declarative Authorization fit my needs.
Thanks for this Ryan! I saw these gems a while back but use mongodb. Is there anyway to use with mongodb not active record or is there another gem you know if that does the same ?
Thanks, Ryan! One of my favorite features of MetaWhere is intelligent hash condition mapping. This means that you can do really complex join operations and still write your wheres just by using the association names. MetaWhere will find the right table name automatically.
See http://metautonomo.us/projects/metawhere/#associations for more.
Very cool screencast Ryan. I had heard about both of these gems before but hadn't seen them in action. The MetaWhere.operator_overload! is also supercool. By the way, Ryan mentioned that both Datamapper and Mongoid have those predicate finders (e.g. :name.gt, :name.lt...etc). Just wanted to let people know that MongoMapper has the same predicate style finders using the custom Plucky gem. Its built into MongoMapper querying. Again awesome screencast
Great screencast Ryan. As I was watching it and noticed how the view determines the search criteria I immediately rose my red flag with security in mind. I was glad you mentioned the security issue and the solution towards the end. Thank you.
@10, just add some flagging and you can sort on your side with the most spam flags you can delete from time to time. This will improve your existing awesome content which you probably spend like hundreds of hours on. Thank you so very much!
Ryan, Thanks for another precise tutorial. I have used MetaWhere with jQGrid and its multisearch feature and thought I might share this. The url from the multisearch contains a json hash. To use the parameters in the hash I did the following in the controller:-
<script src="https://gist.github.com/809192.js"> </script>
and then pass the filters hash to the where(filters). This works very well. However I do not know how to use the parameters coming from the 'groupOp' key of the json hash. Help will be appreciated.
Once again many thanks and hope the above will be of help to a few.
I followed many of your screencasts and your work is amazing, I loved Rails and all the great work you did solved most of my issues that I encountered in the early stages of learning this amazing framework. Keep it up!
Would MetaWhere work with CanCan's 3rd parameter of the can method? If so, that would be great, if not, is there any plan to make the two plugins compatible?
I'm trying to implement this, but I'm stuck. I am carrying a param from a previous page to the index, and when I click on "Search" I get the error "Couldn't find Sla without an ID"... I know I'm doing something dumb, but can someone help me?
Implemented this tutorial on a separate view called "search" so when I click on the search button app will redirect me back to the index and display the results there. What should I do in order to display the results in the "search" view?
Looks like MetaWhere isn't compatible with Rails3.1. Is there another gem like MetaWhere that works with 3.1? There is Squeel, but it uses a funky syntax, and I'd rather stick with something with a syntax that somewhat resembles standard Ruby & Arel.
I try the avatar_or_tag_taggings_tag_name_contains to combine a search on picture model witdh taggings, but widthout success.
Can you help me to do this?
Tested with Rails 3. It's working smoothly with Formtastic too. This looks better than ugly scope based searches. Another great episode! Thanks Ryan.
Very nice screencast! Looks like an elegant way to code an advanced search for a site.
Thanks, it's perfect for creating complex search forms.
Too bad that many nice solutions are hardwired to ActiveRecord and SQL.
I had hoped that ActiveModel would enable them to build things working with MongoDB or Datemapper too.
But it seems those are too different after all.
Its unfortunate that Ben Johnson has dropped off the face of the Earth with Searchlogic and Authlogic. I'd love to see these gems running on Rails 3 but at least Meta Search and Declarative Authorization fit my needs.
Where is twitter or facebook like button
Thanks for this Ryan! I saw these gems a while back but use mongodb. Is there anyway to use with mongodb not active record or is there another gem you know if that does the same ?
thanks
Keep up the great work!
Thanks, Ryan! One of my favorite features of MetaWhere is intelligent hash condition mapping. This means that you can do really complex join operations and still write your wheres just by using the association names. MetaWhere will find the right table name automatically.
See http://metautonomo.us/projects/metawhere/#associations for more.
Really great Screencast! I hat using this SQL code and so I'm happy about this alternative. Why the hack is this not build in standard ActiveRails?
There is a railsdog fork from the searchlogic what is working fully compatible with rails 3
https://github.com/railsdog/searchlogic
gem 'rd_searchlogic', :require => 'searchlogic', :git => 'git://github.com/railsdog/searchlogic.git'
Very cool screencast Ryan. I had heard about both of these gems before but hadn't seen them in action. The MetaWhere.operator_overload! is also supercool. By the way, Ryan mentioned that both Datamapper and Mongoid have those predicate finders (e.g. :name.gt, :name.lt...etc). Just wanted to let people know that MongoMapper has the same predicate style finders using the custom Plucky gem. Its built into MongoMapper querying. Again awesome screencast
Great screencast Ryan. As I was watching it and noticed how the view determines the search criteria I immediately rose my red flag with security in mind. I was glad you mentioned the security issue and the solution towards the end. Thank you.
i might have missed something.. how did you get this nice model printout from a console?
@10, just add some flagging and you can sort on your side with the most spam flags you can delete from time to time. This will improve your existing awesome content which you probably spend like hundreds of hours on. Thank you so very much!
@arkadiy kraportov check out https://github.com/cldwalker/hirb . Ryan covers it quickly on some previous episode.
Excellent screencast! Thank you for always providing such helpful content!
Ryan, Thanks for another precise tutorial. I have used MetaWhere with jQGrid and its multisearch feature and thought I might share this. The url from the multisearch contains a json hash. To use the parameters in the hash I did the following in the controller:-
<script src="https://gist.github.com/809192.js"> </script>
and then pass the filters hash to the where(filters). This works very well. However I do not know how to use the parameters coming from the 'groupOp' key of the json hash. Help will be appreciated.
Once again many thanks and hope the above will be of help to a few.
awesome screencast. sort link helper is cool one in this plugin.
I still miss Searchlogic's field_like_any it was kind of useful for some autocomplete stuff =/
Nicolas: MetaSearch has that. See http://bit.ly/fKXH9Q for the docs.
Definitely nicer than Searchlogic. Thanks, Ryan!
Oooo you beautiful man you! I am just about to start creating a search page with various dropdowns and options etc and his just made my day.
How did we get to the index path when submitting the form_for(@search) without specifying the GET method?
@Junhyun: MetaSearch adjusts the form method automatically in cases where the object supplied is a MetaSearch::Builder (as @search is)
I would like to thank you for your incredible work, creating this wonderful screencast!
(it indeed made me convert from php to rails ;))
Keep it up man, you're doin a great job!
I followed many of your screencasts and your work is amazing, I loved Rails and all the great work you did solved most of my issues that I encountered in the early stages of learning this amazing framework. Keep it up!
Trying to do controller spec for index action with the MetaSearch in the mix but keep bumping into error. Code and error here
https://gist.github.com/827616
I guess this is probably more rspec/mocha related but any hints how to do this correctly?
Would MetaWhere work with CanCan's 3rd parameter of the can method? If so, that would be great, if not, is there any plan to make the two plugins compatible?
I had been waiting for this kind of screencast for a long time. Thanks Ryan.
Has anyone done a "Live Search" with metasearch? Been trying but just can't get it to work.
Ryan, how do you get that mysql style output from rails c? I really like that compared to the default output formatting
Anyone figure out yet now to set a default sort (where one not specified)?
Thanks Ryan.
Here's the cludge I used:
if params[:search].nil?
params[:search] = Hash.new
end
if params[:search][:meta_sort].nil?
params[:search][:meta_sort] = "my_sort_field.desc"
end
You can do this:
@search = Product.search(params[:search])
@search.meta_sort ||= 'name.asc'
(Source: http://craiccomputing.blogspot.com/2010/10/searchlogic-versus-metasearch-and.html )
Can "my_sort_field" be a virtual attributes? I tried but no success. Do you know the way to implement this?
I'm trying to implement this, but I'm stuck. I am carrying a param from a previous page to the index, and when I click on "Search" I get the error "Couldn't find Sla without an ID"... I know I'm doing something dumb, but can someone help me?
Controller:
And the view:
Thanks in advance for any help....
Hi,
Implemented this tutorial on a separate view called "search" so when I click on the search button app will redirect me back to the index and display the results there. What should I do in order to display the results in the "search" view?
maybe a partial view would do it
Hi,
I'd like to clean up the URLs generated by the searches, does anyone know how to do this?
At the moment I'm getting something like this:
http://127.0.0.1:3000/events?utf8=?&search%5Btown_name_equals%5D=&search%5Bgenre_name_equals%5D=DJ+Music&search%5Bdate_equals%5D=&commit=Search
Looks like MetaWhere isn't compatible with Rails3.1. Is there another gem like MetaWhere that works with 3.1? There is Squeel, but it uses a funky syntax, and I'd rather stick with something with a syntax that somewhat resembles standard Ruby & Arel.
Second this request- I like the look and feel of MetaWhere for rails 3, but 3.1 I get conflicts.
Hi,
in my project I use meta_search to implement serching in my model
My controller is:
My _search.html.erb is:
I try the avatar_or_tag_taggings_tag_name_contains to combine a search on picture model witdh taggings, but widthout success.
Can you help me to do this?
Tank in advance
Steve