has_friendship | Add friendship to ActiveRecord models | Application Framework library
kandi X-RAY | has_friendship Summary
kandi X-RAY | has_friendship Summary
Add friendship to ActiveRecord models
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Friendly another friendship
- Fills the errors associated with the friendship
has_friendship Key Features
has_friendship Examples and Code Snippets
Community Discussions
Trending Discussions on has_friendship
QUESTION
I am creating a friendship feature. But I have an issue. When a user is sending a request to a specific user, it is iterating through more than 3k users in order to find the right person. I'd like to know if there is a ruby method which permits to increase the speed of the search.
I'm using the has_friendship gem
Here is my code : View friends : index.html.erb
...ANSWER
Answered 2021-Apr-06 at 08:41I think you can try save user.pseudo
to db and search by that field. You can improve speed with db index.
QUESTION
I have the following code. Adding friend part works well. But afterward I still see the "Add friend" button. So I added <% if... part, but @friendship rendered error (controller code below), so I added <% @friendships.each do... part. Still doesn't work; many "Add friend" on each user show.
...ANSWER
Answered 2020-Jan-06 at 22:52As written it looks like you are looping through every friendship that exists in your database. You only need to loop through the friends of the current user.
Not only will that be a much smaller list, but every member of that list will already be a friend and you won't have to ask whether or not an "Add Friend" link should be displayed.
Consider the following.
First, we restate the models in a slightly different way:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install has_friendship
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page