What is a common approach to scope records by those that an user can “read”?

后端 未结 5 771
太阳男子
太阳男子 2020-12-21 13:11

I am using Ruby on Rails 3.2.2 and I would like to know what is a common approach when it must be checked if an user has proper authorizations to \"read\" records present in

5条回答
  •  南笙
    南笙 (楼主)
    2020-12-21 13:32

    For best performance I would suggest storing list of user readable articles in the session - the user is not going to change within the session and you may consider refresh frequency and/or conditions separately. Assuming that your Articles.list() can be filtered by ids all you will need to do will be to pass the list of user readable ids to Articles.list() functionality. Re user readable list update: you should really update it relatively infrequently - at most once per search, you don' t want to refresh the complete list on every page load for the simple reason that the new results may appear in the pages that user already scrolled through anyway.

提交回复
热议问题