Sha256: 68761c1ef8018bcea0e1b1d139e3deb1ef50df77095660736f13ef7fda09fd25

Contents?: true

Size: 887 Bytes

Versions: 6

Compression:

Stored size: 887 Bytes

Contents

require 'rails/generators'
require 'rails/generators/generated_attribute'

module Redde
  module Generators
    class PhotoGenerator < ::Rails::Generators::Base
      include Rails::Generators::Migration
      source_root File.expand_path('../templates', __FILE__)

      def self.next_migration_number(path)
        Time.now.utc.strftime("%Y%m%d%H%M%S")
      end
      
      def copy_controller
        template "controller.rb", "app/controllers/admin/photos_controller.rb"
      end

      def copy_views
        directory "photos", "app/views/admin/photos"
      end

      def copy_model
        template "photo.rb", "app/models/photo.rb"
      end

      def copy_uploader
        template "uploader.rb", "app/uploaders/photo_uploader.rb"
      end

      def copy_migration
        migration_template "create_photos.rb", "db/migrate/create_photos.rb"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
redde-0.1.7 lib/generators/redde/photo/photo_generator.rb
redde-0.1.6 lib/generators/redde/photo/photo_generator.rb
redde-0.1.5 lib/generators/redde/photo/photo_generator.rb
redde-0.1.4 lib/generators/redde/photo/photo_generator.rb
redde-0.1.3 lib/generators/redde/photo/photo_generator.rb
redde-0.1.2 lib/generators/redde/photo/photo_generator.rb