Skip to content

Instantly share code, notes, and snippets.

@niltonvasques
Created February 16, 2016 07:02
Show Gist options
  • Select an option

  • Save niltonvasques/649c7e39c928d4cdfa42 to your computer and use it in GitHub Desktop.

Select an option

Save niltonvasques/649c7e39c928d4cdfa42 to your computer and use it in GitHub Desktop.
Generate roles for all controllers
roles = Rails.application.routes.routes.map { |route| route.defaults[:controller] }.select { |i| not i.nil? }.uniq.select { |i| not i.match(/\//) }.reduce({}) { |h,i| h[i] = {index: true, new: false, create: false, edit: false, update: false, destroy: false }; h }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment