Sha256: e45197c9dab95a0f077698485c0fae089e326f7f6c751d41e5ba10f9309cabb3

Contents?: true

Size: 963 Bytes

Versions: 24

Compression:

Stored size: 963 Bytes

Contents

require 'rails/generators/active_record'
module Adminpanel
  class GalleryGenerator < ActiveRecord::Generators::Base
    source_root File.expand_path("../templates", __FILE__)
    desc "Generate the resource files necessary to use a model"

    def generate_model
      template 'gallery_template.rb', "app/models/adminpanel/#{lower_name}.rb"
    end

    def generate_uploader
      template 'uploader.rb', "app/uploaders/adminpanel/#{lower_name}_uploader.rb"
    end

    def generate_migration
      migration_template(
        'gallery_migration.rb',
        "db/migrate/create_adminpanel_#{lower_name.pluralize}.rb"
      )
      puts "don't forget to add the form_field, the relationship and #{lower_name}s_attributes it to the permited params"
    end

  private
    def reference_name
      name.singularize.downcase
    end

    def lower_name
      "#{reference_name}file"
    end

    def class_name
      "#{lower_name.capitalize}"
    end

  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
adminpanel-2.6.0 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.5.5 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.5.4 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.5.3 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.5.2 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.5.1 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.5.0 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.4.3 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.4.2 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.4.1 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.4.0 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.3.1 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.3.0 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.2.5 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.2.4 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.2.3 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.2.2 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.2.1 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.2.0 lib/generators/adminpanel/gallery/gallery_generator.rb
adminpanel-2.1.7 lib/generators/adminpanel/gallery/gallery_generator.rb