Skip to content

Instantly share code, notes, and snippets.

@Frank004
Last active September 12, 2017 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Frank004/35f7c98477f71c8d4f73107c58052a21 to your computer and use it in GitHub Desktop.
Save Frank004/35f7c98477f71c8d4f73107c58052a21 to your computer and use it in GitHub Desktop.
user.role.permits.each do |k,v|
controller_name = v[:controller].include?(":") ? (eval(v[:controller])) : (v[:controller].constantize)
can v[:can].map(&:to_sym), controller_name # esto crea dinamicamente los permisos que necesito
end
permits=>{
"inspection_permit"=> {
"controller" => "Inspection",
"inspection_index" => "Yes",
"inspection_show" => "Yes",
"inspection_edit" => "No",
"inspection_destroy" => "No",
"inspection_create" => "Yes",
"inspection_report" => "No",
"inspection_components" => "No"
},
"employee_permit" =>{
"controller" => "Employee",
"settings"=> {
"employee_index" => "Yes",
"employee_show" => "Yes",
"employee_edit" => "Yes",
"employee_destroy" => "Yes",
"employee_create" => "Yes"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment