From 9fffdc5cdb80b1824473a6d7ae1fedf9e74aa748 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 18 Jan 2010 13:44:32 +0100 Subject: Generators load path now will be Ruby load path. If you want to use rspec:install generator, you need generators/rspec/install_generator in your load path. --- .../active_record/model/templates/migration.rb | 16 ++++++++++++++++ .../generators/active_record/model/templates/model.rb | 5 +++++ 2 files changed, 21 insertions(+) create mode 100644 activerecord/lib/generators/active_record/model/templates/migration.rb create mode 100644 activerecord/lib/generators/active_record/model/templates/model.rb (limited to 'activerecord/lib/generators/active_record/model/templates') diff --git a/activerecord/lib/generators/active_record/model/templates/migration.rb b/activerecord/lib/generators/active_record/model/templates/migration.rb new file mode 100644 index 0000000000..1f68487304 --- /dev/null +++ b/activerecord/lib/generators/active_record/model/templates/migration.rb @@ -0,0 +1,16 @@ +class <%= migration_class_name %> < ActiveRecord::Migration + def self.up + create_table :<%= table_name %> do |t| +<% for attribute in attributes -%> + t.<%= attribute.type %> :<%= attribute.name %> +<% end -%> +<% if options[:timestamps] %> + t.timestamps +<% end -%> + end + end + + def self.down + drop_table :<%= table_name %> + end +end diff --git a/activerecord/lib/generators/active_record/model/templates/model.rb b/activerecord/lib/generators/active_record/model/templates/model.rb new file mode 100644 index 0000000000..21ae29e9f2 --- /dev/null +++ b/activerecord/lib/generators/active_record/model/templates/model.rb @@ -0,0 +1,5 @@ +class <%= class_name %> < <%= parent_class_name.classify %> +<% attributes.select {|attr| attr.reference? }.each do |attribute| -%> + belongs_to :<%= attribute.name %> +<% end -%> +end -- cgit v1.2.3