https://avo.cool logo
Join Discord
Powered by
# avo-2
  • e

    elegant-toothbrush-74983

    11/29/2020, 10:28 AM
    Hi guys, saome help please. How to properly scope data in resources? If there are many companies, and user belongs to a company, he should see only data from that company. Where to put this code?
  • e

    elegant-toothbrush-74983

    11/29/2020, 10:33 AM
    #740893011994738751
  • e

    elegant-toothbrush-74983

    11/29/2020, 10:42 AM
    And how to remove "Read the docs for options on how to customize resources." on the dashboard if possible?
  • e

    elegant-toothbrush-74983

    11/29/2020, 10:48 AM
    Oh the filters...
  • l

    lemon-wall-20836

    11/29/2020, 11:24 AM
    Hi Kmet
  • l

    lemon-wall-20836

    11/29/2020, 11:25 AM
    Ofc you can scope the data
  • l

    lemon-wall-20836

    11/29/2020, 11:26 AM
    I’m assuming that the user “data” is a has many relationship
  • l

    lemon-wall-20836

    11/29/2020, 11:26 AM
    Than you can add a has_many field on the user resource
  • l

    lemon-wall-20836

    11/29/2020, 11:27 AM
    Now, when you go on the user show page, below the user details you should get a table with the associated data
  • l

    lemon-wall-20836

    11/29/2020, 11:29 AM
    https://docs.avohq.io/0.x/relations.html#has-many
  • l

    lemon-wall-20836

    11/29/2020, 11:31 AM
    Hmm. Or maybe you’re talking about hiding some data based on the logged in user
  • l

    lemon-wall-20836

    11/29/2020, 11:31 AM
    That’s role based authorization
  • l

    lemon-wall-20836

    11/29/2020, 11:31 AM
    https://docs.avohq.io/0.x/authorization.html#policies
  • l

    lemon-wall-20836

    11/29/2020, 11:32 AM
    You can do that using Pundit policies
  • l

    lemon-wall-20836

    11/29/2020, 11:32 AM
    Add an index scope and you should be good to go
  • e

    elegant-toothbrush-74983

    11/29/2020, 11:34 AM
    Sorry if I'm not clear enough. Scoping data based on logged in user. So if the user opens avo admin and select posts, he needs to see current_user.posts or current_user.company.posts. Or if the current_user opens a Dashboard he needs to see counts only from his company. The Company has xy posts, users etc.
  • l

    lemon-wall-20836

    11/29/2020, 11:35 AM
    Got it
  • e

    elegant-toothbrush-74983

    11/29/2020, 11:35 AM
    Oh great, thanks for the reply Adrian!
  • l

    lemon-wall-20836

    11/29/2020, 11:35 AM
    Yeah, you should use pundit policies to scope data
  • l

    lemon-wall-20836

    11/29/2020, 11:36 AM
    Are you familir with pundit?
  • e

    elegant-toothbrush-74983

    11/29/2020, 11:37 AM
    No, but I will be now 🙂
  • l

    lemon-wall-20836

    11/29/2020, 11:51 AM
    Cool!
  • l

    lemon-wall-20836

    11/29/2020, 12:09 PM
    Regarding the Dashboard, it’s still under development
  • l

    lemon-wall-20836

    11/29/2020, 12:09 PM
    You may hide the documentation and the Resources overview from the general avo.rb config
  • l

    lemon-wall-20836

    11/29/2020, 12:09 PM
    https://docs.avohq.io/0.x/dashboard.html
  • l

    lemon-wall-20836

    11/29/2020, 12:10 PM
    The custom tools and dashboards are going to be pretty cool
  • l

    lemon-wall-20836

    11/29/2020, 12:10 PM
    We’re still working on bringing a cool experience using them
  • e

    elegant-toothbrush-74983

    11/29/2020, 12:40 PM
    Thanks! Really cool project. I will try this out today
  • l

    lemon-wall-20836

    11/29/2020, 1:23 PM
    Thank you!
  • l

    lemon-wall-20836

    11/29/2020, 1:24 PM
    I’m here if I can help some more
12345...64Latest