Permalink
Browse files

added a warning to add model schema to a model and add id as a defaul…

…t property to generated a model
  • Loading branch information...
1 parent 4d7b778 commit 6b8d13e4a55282ce88706cae8e97a55d7a3a2922 @mattetti committed Oct 9, 2008
View
5 merb_datamapper/lib/generators/data_mapper_model.rb
@@ -7,6 +7,11 @@ def datamapper_type(type)
return 'DateTime' if type == 'datetime'
return type.camel_case
end
+
+ def after_generation
+ STDOUT.puts "\n\033[1;32m Don't forget to define the model schema in your #{file_name.capitalize} class\033[0m\n"
+ end
+
end
Merb::Generators::ModelGenerator.template :model_datamapper, :orm => :datamapper do |t|
View
3 merb_datamapper/lib/generators/templates/model.rb
@@ -1,6 +1,9 @@
<% with_modules(modules) do -%>
class <%= class_name %>
include DataMapper::Resource
+
+ property :id, Integer, :serial => true
+
<% attributes.each do |name, type| %>
property :<%= name -%>, <%= datamapper_type(type) -%>
<% end %>

0 comments on commit 6b8d13e

Please sign in to comment.