Ruby on Rails
Tuesday, February 9, 2016
I currently have two models, "User" and "Report". I want to find out the best way of restricting reports from certain user groups.
Given the following three groups...
-- Given the following three groups...
- General Manager
- Store Manager
- Employee
I would like to restrict the users from seeing certain reports.
- General Manager can see all reports - no restrictions
- Store Manager can see their reports and all employee reports
- Employee can see only their own reports
I've currently been restricting access by basically "if" statements in the partials, but it seems like only a matter of time before one of these fails (by my own logic). So the idea came to me to try and set the "default_scope" based on what role the user has... To my knowledge it doesn't work this way though. What would be the equivalent of this though? Or is there a better idea? Thanks!
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-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1be23040-e9e8-4ea4-b8c0-b05b68941213%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment