class HappySeed::Generators::RolesGenerator
Public Class Methods
fingerprint()
click to toggle source
# File lib/generators/happy_seed/roles/roles_generator.rb, line 9 def self.fingerprint gem_available? 'cancancan' end
Public Instance Methods
install_roles()
click to toggle source
# File lib/generators/happy_seed/roles/roles_generator.rb, line 13 def install_roles return if already_installed require_generator DeviseGenerator gem 'cancancan' Bundler.with_clean_env do run "bundle install --without production" run 'rake db:migrate' end template "ability.rb", "app/models/ability.rb" directory "docs" generate 'migration add_role_to_users role:integer' inject_into_class "app/models/user.rb", "User", " enum role: [:user, :admin]\n" inject_into_file 'app/controllers/application_controller.rb', "\n\n def access_denied(exception)\n redirect_to root_path, alert: exception.message\n end\n", before: /\nend/ end