I got this from here, but I don't know where to put and how I will execute this.
I tried to create class and run this thru console (rails c
) but it is not working.
def setup_actions_controllers_db
write_permission("all", "manage", "Everything", "All operations", true)
controllers = Dir.new("#{Rails.root}/app/controllers").entries
controllers.each do |controller|
if controller =~ /_controller/
foo_bar = controller.camelize.gsub(".rb","").constantize.new
end
end
# You can change ApplicationController for a super-class used by your restricted controllers
ApplicationController.subclasses.each do |controller|
if controller.respond_to?(:permission)
clazz, description = controller.permission
write_permission(clazz, "manage", description, "All operations")
controller.action_methods.each do |action|
if action.to_s.index("_callback").nil?
action_desc, cancan_action = eval_cancan_action(action)
write_permission(clazz, cancan_action, description, action_desc)
end
end
end
end
end
and so on ...
Kindly help me on this. Thank you