advanced search

65 views
Skip to first unread message

Artem T

unread,
Dec 16, 2014, 1:13:03 PM12/16/14
to rubyonra...@googlegroups.com
 I have a problem with the implementation of the search in the project


I have such models(
bring a simplified version)

User
   id
   name

Friends
   user_id
   friend_id

Post
  id
  title
  author_id
  is_public

PostDeniedUser
   post_id
   user_id

some explanations:

User can create post. Post can be public or private. If post private only friends of author can see it post, but author can denied access to some friends.


I need to implement search Post by title considering visibility for each user.

some explanations:

User can search in all public posts, in private posts of his friends
which are not denied in one query.

I think create some model SearchPost and like NewsFeed.

duplicate all the data on posts for each user, taking into account the availability of, and then just make an inquiry with the search by title by authorized users

Vivek Sampara

unread,
Dec 17, 2014, 5:26:36 AM12/17/14
to rubyonra...@googlegroups.com
I think you can use rolify as you have dynamic permissions. 

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9a7219ac-e7e1-4b7e-8943-30eadf6ae8c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Message has been deleted

Artem T

unread,
Dec 17, 2014, 8:23:50 AM12/17/14
to rubyonra...@googlegroups.com
I can`t understand how it can help me?

I do not have different roles. All users have one role.

Vivek Sampara

unread,
Dec 17, 2014, 8:36:31 AM12/17/14
to rubyonra...@googlegroups.com
" but author can denied access to some friends. " << this is why it has dynamic roles on individual obejct

On Wed, Dec 17, 2014 at 6:53 PM, Artem T <artt...@gmail.com> wrote:
I can`t understand how it can help me?

I do not have different roles. All users have one role.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.

Artem T

unread,
Dec 17, 2014, 9:03:12 AM12/17/14
to rubyonra...@googlegroups.com
I think this almost my variant. Which is probably even more difficult. Because the query will be contain more JOINS

I need create role reader and then
associate each post with each individual user

What do you think about this?

среда, 17 декабря 2014 г., 15:36:31 UTC+2 пользователь Vivek Sampara написал:

Vivek Sampara

unread,
Dec 17, 2014, 10:08:13 AM12/17/14
to rubyonra...@googlegroups.com
Dont worry about joins , you can use https://github.com/activerecord-hackery/squeel .  I would probably do it this way  

Post name , content ,  :access_type => "Public/Private"
 
PostAccess ( another model ) - user_id , post_id , :type = "Allowed / Denied"   

Artem T

unread,
Dec 17, 2014, 10:17:52 AM12/17/14
to rubyonra...@googlegroups.com

Thanks. And how better to create access posts for users. After all, i need to create a relationship with each user. Delayed_job gem will be good?

17 Дек 2014 г. 17:08 пользователь "Vivek Sampara" <ravens...@gmail.com> написал:
You received this message because you are subscribed to a topic in the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/rubyonrails-talk/gfMiTFsKwFs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to rubyonrails-ta...@googlegroups.com.

To post to this group, send email to rubyonra...@googlegroups.com.

Vivek Sampara

unread,
Dec 17, 2014, 11:29:30 AM12/17/14
to rubyonra...@googlegroups.com
Depends on the type of application. If you think the posts should be appear on the feed immediately after creating then dont go with delayed_job

Artem T

unread,
Dec 17, 2014, 12:00:44 PM12/17/14
to rubyonra...@googlegroups.com

So if user create post he must wait while all post access items created. I may be long time

Artem T

unread,
Dec 17, 2014, 12:00:55 PM12/17/14
to rubyonra...@googlegroups.com

But if in application will be  about1000 or 10000 or more user i need do 1000 or 10000 or more insert queries. To set access for one post( access or denied). Or i not right underatand you?

17 Дек 2014 г. 18:29 пользователь "Vivek Sampara" <ravens...@gmail.com> написал:

Vivek Sampara

unread,
Dec 17, 2014, 12:07:11 PM12/17/14
to rubyonra...@googlegroups.com
:access_type => "Public/Private" 

 :type = "Allowed / Denied" 
if Public then no need to create access. 
if Private create access only those who you want to show / hide 


Reply all
Reply to author
Forward
0 new messages