rolify

Setting up different User models and registration paths for Devise on Ruby on Rails

纵饮孤独 提交于 2019-12-09 23:27:31
问题 I am very new to ruby and I have been really struggling with this for months. I searched extensively and tried what the answers said but still no luck. (I tried Multiple user models with Ruby On Rails and devise to have separate registration routes but one common login route but didnt work) I currently have a user.rb model and it is connected to devise and works fine. 1- On the sign-up page, I would like to have 3 buttons that would lead to separate registration forms (one each for business,

Rails 4 + Rolify Gem: User roles aren't being updated via UI

时光毁灭记忆、已成空白 提交于 2019-12-07 02:46:16
问题 I have an edit view that allows me to update roles for a particular user. I've included the code below, however, just to give you an idea, when I uncheck the boxes on the page, my puts statements in my controller correctly picks up that the role association is false and can be seen further down in the logs. However, later in the logs, you can see that the roles are being re-associated back to 'true' and I'm not sure why that's the case at all! If the checkboxes are unchecked, I want those

Setting up different User models and registration paths for Devise on Ruby on Rails

↘锁芯ラ 提交于 2019-12-04 19:55:47
I am very new to ruby and I have been really struggling with this for months. I searched extensively and tried what the answers said but still no luck. (I tried Multiple user models with Ruby On Rails and devise to have separate registration routes but one common login route but didnt work) I currently have a user.rb model and it is connected to devise and works fine. 1- On the sign-up page, I would like to have 3 buttons that would lead to separate registration forms (one each for business, manager and the already existing user). Do I set this up in routes.rb? 2- The forms will have different

What is the purpose of Rolify?

别来无恙 提交于 2019-12-03 14:53:21
问题 Hi I'm using rolify and have just realized that I'm not actually taking advantage of it's full potential. At present I am doing things in my controller like re-routing users if current_user.has_role? :whatever_role , and allowing users if they have whatever other role... Someone asked a question on stackoverflow about rolify and when I got to trying to answer it, I realized that I'm doing it wrong. Now, here is where my confusion starts... Inside of ability.rb I have: user ||= User.new #

Why is Pundit not coupled with Rolify like CanCanCan is?

泄露秘密 提交于 2019-12-03 09:36:55
问题 I am using Devise and interested in using Pundit but cannot find much on if it should be integrating with Rolify or if it is stand alone. CanCanCan works nicely with Rolify and I like the roles model. Am I missing a major reason why Pundit and Rolify do not seem to be used together a lot? 回答1: Why don't use them together? They can be easily used in a fashion like this class OrganisationPolicy def initialize(user, organisation) @user = user @organisation = organisation end def index? @user.has

What is the purpose of Rolify?

断了今生、忘了曾经 提交于 2019-12-03 04:37:31
Hi I'm using rolify and have just realized that I'm not actually taking advantage of it's full potential. At present I am doing things in my controller like re-routing users if current_user.has_role? :whatever_role , and allowing users if they have whatever other role... Someone asked a question on stackoverflow about rolify and when I got to trying to answer it, I realized that I'm doing it wrong. Now, here is where my confusion starts... Inside of ability.rb I have: user ||= User.new # guest user (not logged in) if user.has_role? :consumer can :manage, Review else can :read, Review end Now

Defining Roles with Rolify

拈花ヽ惹草 提交于 2019-11-27 23:13:47
I am trying to make an app with Rails 4. I am looking at role management and want to use Rolify because it supports instance level role assignment. For others looking at the same problem, there are 2 really good answers below (I can only tick one but I used both). Check out lorefnon & Cyb3rDud3 answers below). I'm still figuring it out, but have made a migration with an array (as lorefnon shows) and the controller/routes functions (as Cyb3rDud3 shows). What is completely baffling me is that all the documents for the Rolify gem use the console to define roles. How do I define roles in my code?

Defining Roles with Rolify

萝らか妹 提交于 2019-11-27 04:39:40
问题 I am trying to make an app with Rails 4. I am looking at role management and want to use Rolify because it supports instance level role assignment. For others looking at the same problem, there are 2 really good answers below (I can only tick one but I used both). Check out lorefnon & Cyb3rDud3 answers below). I'm still figuring it out, but have made a migration with an array (as lorefnon shows) and the controller/routes functions (as Cyb3rDud3 shows). What is completely baffling me is that