I am new new ROR and i am using Ruby 1.9.2 & Rails 3.
My Question is
How to implement ACL in ROR? Jusi like cakephp.
cakephp provide
ACO Database tabel for controller and his action.
ARO Database tabel for usera and his group.
ACO_ARO Database tabel for permission.
I want this type of dynamicall, ACL (Permission) Module in ROR.
Please help.
Related
I am new to ruby on rails
I am developing application which have four users Patient,Doctor,Nurse and Admin i have created patient user using devise now i want to create Admin user which will be used to do all administrative tasks like display all registered patients, etc..
so how can i add the new user to rails application. Do i need to create a new controllers for them
I tried to create the new user by referring this web page
http://rubyonrailshelp.wordpress.com/2014/01/03/creating-user-and-admin-model-using-devise-rails/
but it creates new files and update some existing files when i run this command
$rails generate devise:views
is it there feature or something went wrong i don't have an idea ?
please help
You have to create one devise user table with have one column as role_name:string which will save the your role name (Patient,Doctor,Nurse, Admin) and for admin it should be 'admin'...
And if its one in app then you will create by seed file (app/db/seed.rb)
As User.create(email: , password: , roll_name: 'admin' ) then
rake db:seed
My Ruby on Rails 3 application is using Devise and Cancan.
Concerning the roles, I have admins, managers, users and guests. I have some Posts and I use the generated index function to get my Posts list.
How to ensure that admins can index all the posts, managers can index posts in a specific category only and users can index their own posts only?
Cancan is configured and show me an error message when I am trying to do something I am not authorized to.
My question is how about showing, or not showing, records in views, depending the role ?
check out the documentation:
https://github.com/ryanb/cancan/wiki/Defining-Abilities
https://github.com/ryanb/cancan/wiki/Checking-Abilities
Below is my database schema:
user
uid *
username
user_auth
uid *
password
With this kind of schema, I got big problems with Symfony2 Authenticate. I've read the cookbook at: http://symfony.com/doc/current/cookbook/security/entity_provider.html . But the data model of my project is quite different from the tutorial.
How can I get the password from user_auth for authentication?
Normally, I think about a JOIN query to get both information and then compare them to user's submited data but not well-understanding Doctrine ORM model is blocking me.
Create a custom User Provider where you put your custom user data retrieval logic. Pay attention that your User class must implement UserInterface interface.
I have find out the answer. Using CUSTOM USER PROVIDER.
After that, I stuck at Doctrine ORM for my de-normlize schema. Before give up by changing my schema to fit the ORM, I have tried to map my ORM again after read this tutorial: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/tutorials/composite-primary-keys.html. But it doesn't work as I thought. Then below answers helped me to find out the way.
Symfony 2: INNER JOIN on non related table with doctrine query builder
Having a custom repository with DBAL connection in Symfony 2 / Doctrine 2?
How can I add the Entity Manager to a custom class or service?
'Call to a member function get() on a non-object'?
Now, everything works fine. I'm happy that i can use the DBAL when I need, but not losing the benefit of ORM.
I'm new at RoR but I'm loving every bit of it :)
I have a small app that uses devise for authentication and it's working fine.
Now I want to add a ecommerce part nad I decided for spree. I installed spree and during installation it asked me if I wanted to use the default authentication, I said 'no'. Then it asked me for the user model which I stated 'User'.
Now I enter my app, I login it goes to the products page on spree. That's ok, but when I try to access the admin part, I get redirected to the products page.
My doubts are:
- Should I install anyway the spree_auth_devise gem?
- Should this be a problem with the database and the users role? Because on the "spree_users" table I don't have anything, only on the Users table...
How can I associate one of my existing users to an admin user on spree?
Should this be the problem or I'm missing something else?
Did you run this:
rails g spree:custom_user User
http://guides.spreecommerce.com/authentication.html in the Initial Setup block
To check is user is admin:
user = User.find_by_email("master#example.com")
user.spree_roles << Spree::Role.find_or_create_by_name("admin")
## To test that this has worked, use the has_spree_role? method, like this:
user.has_spree_role?("admin")
This is probably a simple question, but as I have never gone through the process thought I would seek assistance. I am using devise for my user authentication in my rails 3 app. Rather than create a seperate model for my 1 admin user i would like to set a user with admin => TRUE.
I have my User DB setup ready to go ( have added Admin column in the USER DB).
My question is how do i create a User so that the admin flag is set to TRUE. Would this be done in the console, if so what would the command look like?
All help appreciated
Check out section Listing 9.41. of Michael Hartl's tutorial.
User.toggle!(:admin)
or as I prefer:
u = User.find(1)
u.toggle!(:admin)