Ruby on Rails
Vložit
- čas přidán 8. 05. 2024
- "Global search" allows you to search multiple attributes of multiple models in a single search form.
For example, on superails.com when you perform a search in the navbar you get results for Posts, Tags, Playlists.
We will build a scalable global search, so that you can easily add new models and attributes to search on.
This video topic was suggested by @Elgnonvis . Want me to do a video about a topic? Add your ideas in the ocmments.
Episode source code: github.com/corsego/150-global...
Based on this blogpost: blog.corsego.com/search-multi...
0:00 Global Search examples
2:02 Basic global search
11:02 Advanced global search
23:30 Final demo
Wow!
Here we are!
Thanks a lot
🎉🎉🎉
Please make a video for ignoring diacritics in search. Thank you!
Супер. Дякую😊
Thank you.
I came here from the Ruby documentary on honeypot. How do I install ruby on a LAMP stack server? 😭😭😭 I want to learn it, it sounds easy.
Hi, nice to meet you! Rails was the first thing I learned when starting programming = definitely easy to start 😅
To install it, try visiting rails.new and running the script
the easy way is using wsl in windows, you have a linux environment and you just need apt get to install anything, i mean with anything, ruby, rails and nodejs, nodejs to use external css libraries like tailwind
i do my own implementation of searching, i use inject to create nested where and or, everything but start with q_ will be filtered and q_ will be filtered using or, rails use in when the condition is an array, inject is awesome, that blow my mind, rails calls inject recursively
How would you include a rich text attribute in the controller index method?
This rather messy approach works but is there a more succinct syntax:
@posts = Post.includes(:rich_text_description).joins("INNER JOIN action_text_rich_texts ON action_text_rich_texts.record_id = posts.id").where("posts.name ILIKE ? OR action_text_rich_texts.body LIKE ?", "%#{params[:query]}%", "%#{params[:query]}%").uniq
It's sql. It's fine.