Created
August 10, 2013 00:32
-
-
Save rlmattax/6198434 to your computer and use it in GitHub Desktop.
Active Admin + Rolify -- A simple example of modifying roles within active admin on users.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveAdmin.register User do | |
index do | |
column "ID" do |user| | |
link_to user.id, admin_user_path(user) | |
end | |
... | |
column :roles do |user| | |
user.roles.collect {|c| c.name.capitalize }.to_sentence | |
end | |
default_actions | |
end | |
show do |ad| | |
attributes_table do | |
row :id | |
... | |
row :roles do |user| | |
user.roles.collect {|r| r.name.capitalize }.to_sentence | |
end | |
end | |
end | |
form do |f| | |
f.inputs "User Details" do | |
... | |
f.input :roles, :collection => Role.global, | |
:label_method => lambda { |el| t "simple_form.options.user.roles.#{el.name}" } | |
end | |
f.actions | |
end | |
controller do | |
def update | |
params[:user].each{|k,v| resource.send("#{k}=",v)} | |
super | |
end | |
def permitted_params | |
params.permit user: [ ..., :role_ids] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did this work for you?