Sha256: f8cf3fc6341dcee785d33ef489b35d8bd3098731380ee5db646524e71edd24e8

Contents?: true

Size: 983 Bytes

Versions: 13

Compression:

Stored size: 983 Bytes

Contents

require 'rails/generators/migration'

    class SettingsGenerator < Rails::Generators::NamedBase
      include Rails::Generators::Migration
  
      argument :name, :type => :string, :default => "my_settings"
  
      source_root File.expand_path('../templates', __FILE__)  
  
      @@migrations = false
      
      def self.next_migration_number(dirname) #:nodoc:
        if ActiveRecord::Base.timestamped_migrations
          if @@migrations          
            (current_migration_number(dirname) + 1)
          else
            @@migrations = true
            Time.now.utc.strftime("%Y%m%d%H%M%S")
          end
        else
          "%.3d" % (current_migration_number(dirname) + 1)
        end
      end  

      def settings      
        #generate(:model, name, "--skip-migration")
        template "model.rb", File.join("app/models",class_path,"#{file_name}.rb"), :force => true
        migration_template "migration.rb", "db/migrate/create_settings.rb"
      end
    end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
rails-settings-cached-0.4.1 lib/generators/settings/settings_generator.rb
rails-settings-cached-0.4.0 lib/generators/settings/settings_generator.rb
rails-settings-cached-0.3.2 lib/generators/settings/settings_generator.rb
rails-settings-rails32-0.1.2 lib/generators/settings/settings_generator.rb
rails-settings-cached-0.3.1 lib/generators/settings/settings_generator.rb
rails-settings-cached-0.3.0 lib/generators/settings/settings_generator.rb
rails-settings-cached-0.2.4 lib/generators/settings/settings_generator.rb
rails-settings-cached-0.2.3 lib/generators/settings/settings_generator.rb
rails-settings-cached-0.2.2 lib/generators/settings/settings_generator.rb
rails-settings-cached-0.2.1 lib/generators/settings/settings_generator.rb
rails-settings-cached-0.2.0 lib/generators/settings/settings_generator.rb
rails-3-settings-0.1.1 lib/generators/settings/settings_generator.rb
rails-settings-cached-0.1.2 lib/generators/settings/settings_generator.rb