diff options
author | francis <francis> | 2007-09-10 18:58:42 +0000 |
---|---|---|
committer | francis <francis> | 2007-09-10 18:58:42 +0000 |
commit | 2f61ce926c4311ff95597c1c871081a1fb46a4d6 (patch) | |
tree | e59a0e989b31e51a6069c8426840ec4db95dc26b /app/models | |
parent | 022f7a0d72a7742875d9ba94ce33a4ec069d36dd (diff) |
Model for outgoing messages.
Save body of initial request as an outgoing message.
Try and validate and save the pair of models correctly.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/info_request.rb | 3 | ||||
-rw-r--r-- | app/models/outgoing_message.rb | 23 |
2 files changed, 25 insertions, 1 deletions
diff --git a/app/models/info_request.rb b/app/models/info_request.rb index 21f9e47cb..c354fb3af 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -4,11 +4,12 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: francis@mysociety.org; WWW: http://www.mysociety.org/ # -# $Id: info_request.rb,v 1.3 2007-09-10 01:16:35 francis Exp $ +# $Id: info_request.rb,v 1.4 2007-09-10 18:58:43 francis Exp $ class InfoRequest < ActiveRecord::Base belongs_to :user belongs_to :public_body + has_many :outgoing_message # validates_presence_of :user # validates_numericality_of :user diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb new file mode 100644 index 000000000..186bb2147 --- /dev/null +++ b/app/models/outgoing_message.rb @@ -0,0 +1,23 @@ +# models/outgoing_message.rb: +# A message, associated with a request, from the user of the site to somebody +# else. e.g. An initial request for information, or a complaint. +# +# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. +# Email: francis@mysociety.org; WWW: http://www.mysociety.org/ +# +# $Id: outgoing_message.rb,v 1.1 2007-09-10 18:58:43 francis Exp $ + +class OutgoingMessage < ActiveRecord::Base + belongs_to :info_request + validates_presence_of :info_request_id + + validates_presence_of :body + validates_inclusion_of :status, :in => ['ready', 'sent', 'failed'] + + belongs_to :public_body + validates_inclusion_of :message_type, :in => ['initial_request'] #, 'complaint'] + + belongs_to :recipient, :polymorphic => true + +end + |