simplybuilt / simonsays Goto Github PK
View Code? Open in Web Editor NEW๐ Simple, declarative, role-based access control system for Rails and Ruby
License: MIT License
๐ Simple, declarative, role-based access control system for Rails and Ruby
License: MIT License
I have a Devise User model with 3 subtypes "Player", "Hero" and "Coach". Each of the subtypes have their own set of roles. However, I only seem to be able to add one set of roles to a user. If I try to add a different set of roles to a different user type the roles mask is 0 with an empty roles array.
Simplified example:
class User < ApplicationRecord
before_create :add_roles
include SimonSays::Roleable
has_roles :content_creator, :story_admin, :advertiser, :promoter, :team_admin
private
def add_roles
case self.type
when 'Player'
self.roles = %i[content_creator story_admin]
when 'Hero'
self.roles = %i[content_creator story_admin]
when 'Coach'
self.roles = %i[promoter team_admin]
end
end
end
Outcome:
Player.create!({params})
Player.first.roles
# [:content_creator, :story_admin]
Hero.create!({params})
Hero.first.roles
# [:content_creator, :story_admin]
Coach.create!({params})
Coach.first.roles
# []
Every time I try to add a different set of roles to a User type the roles array comes up empty. Any advice on how to solve this issue?
This option will let you specify an attribute other than :id
for the find queries with find_resource
and find_and_authorized
.
Hi, I work at @knotchlabs my company uses this gem in production. We love it and respect your work but I'd like to see it come out of Alpha.
Is there a 1.0 release schedule available? If you need help one of our core engineers @mjc-gh has plenty of free cycles and he would be more than happy to jump in and help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.