Ask A Question

Notifications

You’re not receiving notifications from this thread.

Search functionality for the screencasts

harsha vardhan mudumba venkata asked in Site Feedback

It would be great if can search through the screencasts. You will definitely need one once the number of screencasts increase.

Reply

That's a good idea. I'll hook that in soon.

Reply

Hate to bump an old topic, but doing a screencast on search would really be useful. i.e. writing search from scratch that can search through multiple models and associations. CodeSchool's FeatureFocus did something like this with DHH writing something wicked, figured you might want to write some search instead of using a gem like ransack. Would be a good learning opportunity for the GoRails community.

Reply

Like this? :) https://gorails.com/episodes/forum-search-with-ransack

I can't remember if I talk about going through multiple models, but it's about as simple as making your search field names include the two model names.

Reply

Yes, this is good but I was thinking of doing one where the search functionality is written from scratch. It would be cool to write something like this. In fact I'm in the middle of writing some complex search without using Ransack or Elastic. If you want some help on a screencast, let me know.

Reply

Ah interesting. How come you're going with a custom search?

Reply

Same reason I'm trying to write my own version of Devise and CanCanCan, practice :)

Ransack would probably take care of everything I need, but I'm fascinated as of late with writing things from scratch.

Reply

I just followed the ransack tutorial. got it up and running great in development but when I pushed to heroku I get this error...

Heroku logs:

2015-01-24T01:54:38.069528+00:00 app[web.1]: PG::UndefinedFunction: ERROR: operator does not exist: timestamp without time zone ~~* unknown
2015-01-24T01:54:38.069537+00:00 app[web.1]: HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
2015-01-24T01:54:38.072276+00:00 app[web.1]: ActionView::Template::Error (PG::UndefinedFunction: ERROR: operator does not exist: timestamp without time zone ~~* unknown
2015-01-24T01:54:38.072298+00:00 app[web.1]: app/controllers/pins_controller.rb:20:in `index'
2015-01-24T01:54:38.072281+00:00 app[web.1]: HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
2015-01-24T01:54:38.072301+00:00 app[web.1]:
2015-01-24T01:54:38.069538+00:00 app[web.1]: : SELECT DISTINCT "pins".* FROM "pins" LEFT OUTER JOIN "users" ON "users"."id" = "pins"."user_id" WHERE (("users"."name" ILIKE '%Bobby Romelo%' OR "pins"."created_at" ILIKE '%%'))
2015-01-24T01:54:38.072278+00:00 app[web.1]: LINE 1: ...me" ILIKE '%Bobby Romelo%' OR "pins"."created_at" ILIKE '%%'...

Any ideas on what's going on?

Reply

It looks like you're trying to do a string comparison on the created_at timestamp. I think you want to use created_at_gteq instead of created_at_cont in your search form.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.