diff options
author | José Valim <jose.valim@gmail.com> | 2009-06-27 13:03:07 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-06-27 21:29:59 +0200 |
commit | 8c5622f0d4d3b5c6bce52b0eb22756a83060b1b1 (patch) | |
tree | a09d54d92582028e343d731fa9fafef352145119 /railties/lib/generators/active_record/model/templates | |
parent | 9acb721e6a4e78bdd1b9d5f9fb80f4ed2b263b34 (diff) | |
download | rails-8c5622f0d4d3b5c6bce52b0eb22756a83060b1b1.tar.gz rails-8c5622f0d4d3b5c6bce52b0eb22756a83060b1b1.tar.bz2 rails-8c5622f0d4d3b5c6bce52b0eb22756a83060b1b1.zip |
Initial scratch of model generators.
Diffstat (limited to 'railties/lib/generators/active_record/model/templates')
-rw-r--r-- | railties/lib/generators/active_record/model/templates/migration.rb | 16 | ||||
-rw-r--r-- | railties/lib/generators/active_record/model/templates/model.rb | 5 |
2 files changed, 21 insertions, 0 deletions
diff --git a/railties/lib/generators/active_record/model/templates/migration.rb b/railties/lib/generators/active_record/model/templates/migration.rb new file mode 100644 index 0000000000..382fd1156e --- /dev/null +++ b/railties/lib/generators/active_record/model/templates/migration.rb @@ -0,0 +1,16 @@ +class <%= migration_name %> < ActiveRecord::Migration + def self.up + create_table :<%= table_name %> do |t| +<% for attribute in attributes -%> + t.<%= attribute.type %> :<%= attribute.name %> +<% end -%> +<% unless options[:skip_timestamps] %> + t.timestamps +<% end -%> + end + end + + def self.down + drop_table :<%= table_name %> + end +end diff --git a/railties/lib/generators/active_record/model/templates/model.rb b/railties/lib/generators/active_record/model/templates/model.rb new file mode 100644 index 0000000000..0656b06dfe --- /dev/null +++ b/railties/lib/generators/active_record/model/templates/model.rb @@ -0,0 +1,5 @@ +class <%= class_name %> < ActiveRecord::Base +<% attributes.select {|attr| attr.reference? }.each do |attribute| -%> + belongs_to :<%= attribute.name %> +<% end -%> +end |