FAQ Database Discussion Community


How to check rolify with a helper in rails?

ruby-on-rails,rolify
I want to make some helpers for my rolify methods. So, I've created the following: Users helper module UsersHelper #Check if current user is admin def admin_check if current_user if current_user.has_role? :admin end end #Check if current user is pro and admin def admin_and_pro_check if current_user if current_user.has_any_role? :admin, :pro...

Devise and Rolify - Display all of users - roles — Multiple Roles

devise,user,roles,rolify
I have a view that shows the user and roles. I can get it to show all of the users and a single role with user.roles.first.name. I cant get it to loop and retrieve all roles for the user selected. Any help would be wonderful. <h1>Admin#users</h1> <p>Find me in app/views/admin/users.html.erb</p>...

Dynamic permissions rubygem?

ruby-on-rails,ruby,rolify
Is there a framework or common pattern for implementing dynamic permissions? Something like Rolify but where I wouldn't have to restart the server. I guess I could just iterate through each User that has a role and add/remove permissions but that seems like overwork....

When updating a nested form, how do I do something with new records?

ruby-on-rails,ruby,nested-forms,rolify
class Photo < ActiveRecord::Base has_many :item_photos has_many :items, through: :item_photos end class Item < ActiveRecord::Base has_many :item_photos has_many :photos, through: :item_photos accepts_nested_attributes_for :photos end class ItemPhotos < ActiveRecord::Base belongs_to :photo belongs_to :item end When I edit or create an Item, I also upload or remove Photos. However, more than one...

Rails + Rolify Gem: Assigning an :admin role to ALL users in a table

ruby-on-rails,ruby-on-rails-4,rolify
I am using the Rolify gem (https://github.com/RolifyCommunity/rolify) to assign roles to users of my web app. I understand from the documentation that I can do this to assign a role to an individual user record: user = User.find(1) user.add_role :admin Which is fine, and what I'm doing with new accounts...