Hello guys i want to implement rbac autorisation for a rails app.
i use devise to generate user and i have a product controllers.
am a beginners at rails and i want to use:
user role show
admin role edit
speruser role delete
I don’t know how to implement this i use cancan and i have a problem to affect a role to a user
I use devise and cancancan for login and roles.
In my little rails app generator project: https://github.com/dgleba/bashrail there are scripts for this. Even if you don’t use the scripts, they document exactly how to implement it in that case.
When I am learning something like this I strip the scripts down to just what is needed to create an app with the feature I am studing.
This app, https://github.com/dgleba/brail351d, was generated by bashrail and has fully functional roles like mention in your question.
i want to use your script to test how implement robe based access control .
I hav a problems to import this or to add some file in my projet.
I can’t see the views who create user our assign a role to a user its my matter.
help need if i could have our contact to communicate fastly.
need u david Dleba
What operating system are you using?
Can you download the bashrail project to your PC and follow the instructions in the README.md.
I wonder if you can run it as it is and see if it generates a rails app you can run. Then we can break it down into smaller pieces and try to understand what it is doing.
I use mac os x.
I want to use your app to see specifically how use Rbac in a simple app.
And in my app i don’t undertand how to link user to a specifique role.
in devise/ folder i can’t see an in the form how to add role id
and if i want to add user in the seed file i have a error.
The role_id is a column in the users table.
The role.rb model and the user.rb model are related.
In user.rb the roles are processed.
I find it is helpful to try to add the feature you want to a fresh plain test project.
When you can add it to a test project, then try to add it to your project.
Also, my implementation was patterned after this article.
Maybe that will help you also.
Can you post specific error messages, screen shots, code, etc? I may be able to answer specifically.
yeah i see this moment i create a simple web app i use devise and cancancan
but i cant creer a select form to insert role id in the database for using html files devise/registrations.
In your github i dont undertand how to use its when i import then i have many thing aborted
I go to create a teste app using https://hibbard.eu/authentication-with-devise-and-cancancan-in-rails-4-2/
simple user project and role.
If it will run normally i could contact you else i i give you our mistake
hi i have a mistake since this morning .
undefined method `name’ for nil:NilClass
Extracted source (around line #15):
self.role.name == "Admin"
self.role.name == "Seller"
As the error says, self.role is nil
the error says no MethodError (undefined method `name’ for nil:NilClass):
I see that in one spot you have Admin - capitalized. and in another it is not capitalized - admin.
I wonder if capitalization matters in your code.
Note that we can’t see your code. That makes it harder to help you when we can’t see the code.
The article has an app in github.
Can you download it and run it successfully?
yeah in this i want to know how do to insert a new users using user view or devise and respected role.
in my userscontroller if i put at the top: before_filter :authentificate_user i hav and error saying
the error says no MethodError (undefined method `name' for nil:NilClass):
Exactly. The error says you have tried to call method 'name' on
something that is nil. You are calling method 'name' on self.role (you
have used self.role.name) therefore the error is saying that self.role
I may not be answering your question on this one, but I just an admin tool to add a user since the administrator of the system must grant the proper role to the new user.
So, if am using rails_admin with the project, add the user in that tool and assign the appropriate role_id.
The code can also be setup so a user can sign-up them selves and a default role is assigned.
You can also add a user with a tool such as phpmyadmin, pgadmin, sqlite-browser like http://sqlitebrowser.org/.
yeah its great david i havent problem if i had a user in my seed file (for example) and then i need to add new role new user or new item for my html.erb file and i don’t know how i do to link user and item if i add item example.
Second wan’t to know if its possible to use your projet (david ) to verify something for my user role and admin
(need to import new projet and doing test for this)
For your second item:
I suggest that you download this: GitHub - dgleba/brail347a22
- cp config/database-example.yml config/database.yml
- cp config/application-example.yml config/application.yml
- cp config/secrets-example.yml config/secrets.yml
I see your git i check this 2 item and i import your implementation for testing.
for the first step my friend say me to use this git https://github.com/605data/strongbolt_example and for me i have this information for your git brail.
You suggest me the strong bolt guide or your example.
For the first item 1:
i see the problem was solved. In a simple example if i add user or item or role at the seed.rb file it run normally and me i need to add user or item in the html.erb file?