Skip to content

Instantly share code, notes, and snippets.

@1xch
Created October 11, 2011 16:39
Show Gist options
  • Save 1xch/1278627 to your computer and use it in GitHub Desktop.
Save 1xch/1278627 to your computer and use it in GitHub Desktop.
```
class Ticket
include DataMapper::Resource
if Rails::DataMapper.configuration.repositories["development" || "test" || "production"]["ticketengine"]
def self.default_repository_name
:ticketengine
end
end
property :id, Serial
timestamps :at
property :slug, String, :default=> lambda { |r,p| rand(2**1024).to_s(36)[13..19]}# unique slug as restful endpoint for ticket
property :ticket_type, String, :default => "ticket" # start creating types of tickets and sorting by e.g. suggestions, technical issues
property :title, String, :default=> lambda { |r,p| r.content[0..25]+"... " } # useful in some listing ?generate as needed or store here, which is quicker?
property :content, Text, :length => (1..2000)
property :priority, Enum[:null,:lowlow,:low,:medium,:high,:highhigh,:ultra], :default=>:medium
property :status, Enum[:open,:closed], :default =>:open
validates_uniqueness_of :slug
remix n, :comments
def to_param
self.slug
end
end
```
@1xch
Copy link
Author

1xch commented Oct 11, 2011

module Comment
  include DataMapper::Resource
  is :remixable

  if Rails::DataMapper.configuration.repositories["development" || "test" || "production"]["ticketengine"]
    def self.default_repository_name
     :ticketengine
    end
  end

  property :id,            Serial
  property :body,          Text, :length=>1..300
  property :created_at,    DateTime
  property :created_by,    String
  property :commentfilter, String #useful to filter comments by situation

end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment