Skip to content

Commit

Permalink
added a warning to add model schema to a model and add id as a defaul…
Browse files Browse the repository at this point in the history
…t property to generated a model
  • Loading branch information
mattetti committed Oct 9, 2008
1 parent 4d7b778 commit 6b8d13e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions merb_datamapper/lib/generators/data_mapper_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
3 changes: 3 additions & 0 deletions merb_datamapper/lib/generators/templates/model.rb
Original file line number Diff line number Diff line change
@@ -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 %>
Expand Down

0 comments on commit 6b8d13e

Please sign in to comment.