Sha256: e886516ee3374d682109aae14feb10ebc6874e82acff92280686a7fa49eb8413

Contents?: true

Size: 782 Bytes

Versions: 11

Compression:

Stored size: 782 Bytes

Contents

require 'rails/generators'

module Pages
  module Generators
    class RolesGenerator < ::Rails::Generators::Base
      source_root File.expand_path("../templates", __FILE__)

      desc "Simple role-based authorization. A User model with roles must be available."

      def add_users_partial
        copy_file 'users/_user.html.erb', 'app/views/users/_user.html.erb'
      end

      def add_if_devise
        return unless File.exists?('config/initializers/devise.rb')
        copy_file 'devise/users_controller.rb', 'app/controllers/users_controller.rb'
      end

      def add_if_omniauth
        return unless File.exists?('config/initializers/omniauth.rb')
        copy_file 'omniauth/users_controller.rb', 'app/controllers/users_controller.rb'
      end

    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rails_apps_pages-0.6.7 lib/generators/pages/roles/roles_generator.rb
rails_apps_pages-0.6.6 lib/generators/pages/roles/roles_generator.rb
rails_apps_pages-0.6.5 lib/generators/pages/roles/roles_generator.rb
rails_apps_pages-0.6.4 lib/generators/pages/roles/roles_generator.rb
rails_apps_pages-0.6.3 lib/generators/pages/roles/roles_generator.rb
rails_apps_pages-0.6.2 lib/generators/pages/roles/roles_generator.rb
rails_apps_pages-0.6.0 lib/generators/pages/roles/roles_generator.rb
rails_apps_pages-0.5.16 lib/generators/pages/roles/roles_generator.rb
rails_apps_pages-0.5.15 lib/generators/pages/roles/roles_generator.rb
rails_apps_pages-0.5.14 lib/generators/pages/roles/roles_generator.rb
rails_apps_pages-0.5.13 lib/generators/pages/roles/roles_generator.rb