class Petergate::Generators::InstallGenerator
Public Class Methods
next_migration_number(path)
click to toggle source
# File lib/generators/petergate/install_generator.rb, line 11 def self.next_migration_number(path) sleep 1 Time.now.utc.strftime("%Y%m%d%H%M%S") end
Public Instance Methods
create_migrations()
click to toggle source
RUBY end
end
# File lib/generators/petergate/install_generator.rb, line 42 def create_migrations Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath| name = File.basename(filepath) migration_template "migrations/#{name}", "db/migrate/#{name}" end end
insert_into_user_model()
click to toggle source
# File lib/generators/petergate/install_generator.rb, line 16 def insert_into_user_model inject_into_file "app/models/user.rb", after: /^class\sUser < ActiveRecord::Base|^class User < ApplicationRecord/ do <<-'RUBY' ############################################################################################ ## PeterGate Roles ## ## The :user role is added by default and shouldn't be included in this list. ## ## The :root_admin can access any page regardless of access settings. Use with caution! ## ## The multiple option can be set to true if you need users to have multiple roles. ## petergate(roles: [:admin, :editor], multiple: false) ## ############################################################################################ RUBY end end