bullet-train-co / bullet_train-roles Goto Github PK
View Code? Open in Web Editor NEWBullet Train Roles provides a Yaml-based configuration layer on top of CanCanCan.
License: MIT License
Bullet Train Roles provides a Yaml-based configuration layer on top of CanCanCan.
License: MIT License
Examples I think should be valid:
editor:
models:
project:
- archive
- where:
- archived_at: nil
Would be like: can :archive, Project, [all the other magic], archived_at: nil
editor:
models:
project:
- archive
- where:
- workspace:
- archived_at: nil
Would be like: can :archive, Project, [all the other magic], workspace: {archived_at: nil}
When doing membership.roles = [Role.admin]
we should automatically save the change to make it behave more like Rails' has_many :through association.
It will also make upgrading easier because existing Bullet Train apps that assign roles using the membership.roles = [Role.admin]
syntax won't need to change any code when upgrading to the gem.
@adampal Only you can do this. :-)
The Roles::User module could be named better.
It will often be a User, however we're really wanting to include this module in any class that could be the end owner of the roles. Roles are applied to a Membership, however the User actually owns the roles.
I think Roles::Owner
would be a better choice.
crud
should be shorthand for create
, read
, update
, destroy
. This is different than manage
, because manage
includes any action (e.g. approve
, etc.), vs. just standard CRUD workflow stuff.
Instead, I think we'll need to remove the attempt to set a default
on the column when we generated the migration, and instead do this in the model:
after_initialize :set_default_role_ids
def set_default_role_ids
self.role_ids ||= []
end
What I think should be valid examples:
editor:
models:
project:
- manage
- not: destroy
editor:
models:
project:
- manage
- not:
- destroy
See comment here:
#20 (comment)
tl;dr - we're adding a different levels of caching in #20 and #21. To avoid confusion we need to explicitly name the permit
method arguments.
When upgrading from 1.0.4 to 1.0.5, Bullet Train's Super Scaffolding system test fails. To reproduce, remove the 1.0.4
version lock in the Gemfile
, bundle install
, and:
test/bin/setup-super-scaffolding-system-test
rails test test/system/super_scaffolding_test.rb
Seems like in the process of adding support for team_id
being denormalized onto a given child model, we broke the support for has_one :team, through: ...
.
2.7.2 :006 > Ability.new(User.last).can? :create, Scaffolding::AbsolutelyAbstract::CreativeConcept
User Load (0.6ms) SELECT "users".* FROM "users" ORDER BY "users"."id" DESC LIMIT $1 [["LIMIT", 1]]
Membership Load (0.2ms) SELECT "memberships".* FROM "memberships" WHERE "memberships"."user_id" = $1 [["user_id", 1]]
Traceback (most recent call last):
16: from railties (6.1.3.2) lib/rails/commands/console/console_command.rb:102:in `perform'
15: from railties (6.1.3.2) lib/rails/commands/console/console_command.rb:19:in `start'
14: from railties (6.1.3.2) lib/rails/commands/console/console_command.rb:70:in `start'
13: from (irb):6
12: from (irb):6:in `new'
11: from app/models/ability.rb:41:in `initialize'
10: from bullet_train-roles (f5992fb490db) lib/roles/permit.rb:15:in `permit'
9: from bullet_train-roles (f5992fb490db) lib/roles/permit.rb:15:in `each'
8: from bullet_train-roles (f5992fb490db) lib/roles/permit.rb:19:in `block in permit'
7: from bullet_train-roles (f5992fb490db) lib/roles/permit.rb:44:in `add_abilities_for'
6: from bullet_train-roles (f5992fb490db) lib/models/role.rb:99:in `ability_generator'
5: from bullet_train-roles (f5992fb490db) lib/models/role.rb:99:in `each'
4: from bullet_train-roles (f5992fb490db) lib/models/role.rb:100:in `block in ability_generator'
3: from bullet_train-roles (f5992fb490db) lib/models/role.rb:100:in `new'
2: from bullet_train-roles (f5992fb490db) lib/models/role.rb:147:in `initialize'
1: from activemodel (6.1.3.2) lib/active_model/attribute_methods.rb:469:in `method_missing'
NoMethodError (undefined method `parent_ids_for' for #<User:0x0000000114d6def8>)
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.