class WnwPermissible::InstallGenerator
Installs PaperTrail in a rails app.
Constants
- MODELS
Public Class Methods
next_migration_number(dirname)
click to toggle source
# File lib/generators/wnw_permissible/install_generator.rb, line 50 def self.next_migration_number(dirname) ::ActiveRecord::Generators::Base.next_migration_number(dirname) end
Public Instance Methods
create_migration_files()
click to toggle source
# File lib/generators/wnw_permissible/install_generator.rb, line 33 def create_migration_files migration_dir = File.expand_path("db/migrate") MODELS.each do |template| template_name = "create_#{template.pluralize}" if self.class.migration_exists?(migration_dir, template_name) ::Kernel.warn "Migration already exists: #{template_name}" else migration_template( "#{template_name}.rb.erb", "db/migrate/#{template_name}.rb", :migration_version => migration_version ) end end end
create_model_files()
click to toggle source
# File lib/generators/wnw_permissible/install_generator.rb, line 23 def create_model_files MODELS.each do |model| if File.exist? File.join(destination_root,'app','models',"#{model}.rb") ::Kernel.warn "Migration already exists: #{model}.rb" else template "model.rb.erb", "app/models/#{model}.rb", :model => model end end end
migration_version()
click to toggle source
# File lib/generators/wnw_permissible/install_generator.rb, line 54 def migration_version major = ActiveRecord::VERSION::MAJOR if major >= 5 "[#{major}.#{ActiveRecord::VERSION::MINOR}]" end end