diff --git a/app/controllers/dmails_controller.rb b/app/controllers/dmails_controller.rb index b58d65b26..2d1fdb4f8 100644 --- a/app/controllers/dmails_controller.rb +++ b/app/controllers/dmails_controller.rb @@ -37,7 +37,7 @@ class DmailsController < ApplicationController end def create - @dmail = Dmail.create_split(params[:dmail]) + @dmail = Dmail.create_split(params[:dmail].merge(:creator_ip_addr => request.remote_ip)) respond_with(@dmail) end diff --git a/app/models/dmail.rb b/app/models/dmail.rb index 7205551ef..6cdac3502 100644 --- a/app/models/dmail.rb +++ b/app/models/dmail.rb @@ -10,7 +10,7 @@ class Dmail < ActiveRecord::Base belongs_to :from, :class_name => "User" after_create :update_recipient after_create :send_dmail - attr_accessible :title, :body, :is_deleted, :to_id, :to, :to_name + attr_accessible :title, :body, :is_deleted, :to_id, :to, :to_name, :creator_ip_addr module AddressMethods def to_name diff --git a/db/migrate/20140221213349_add_ip_addr_to_dmails.rb b/db/migrate/20140221213349_add_ip_addr_to_dmails.rb new file mode 100644 index 000000000..e0cc7c018 --- /dev/null +++ b/db/migrate/20140221213349_add_ip_addr_to_dmails.rb @@ -0,0 +1,5 @@ +class AddIpAddrToDmails < ActiveRecord::Migration + def change + add_column :dmails, :creator_ip_addr, :inet, :null => false, :default => "127.0.0.1" + end +end diff --git a/db/structure.sql b/db/structure.sql index 492df159c..8adbb3d1e 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -849,7 +849,8 @@ CREATE TABLE dmails ( is_read boolean DEFAULT false NOT NULL, is_deleted boolean DEFAULT false NOT NULL, created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL + updated_at timestamp without time zone NOT NULL, + creator_ip_addr inet DEFAULT '127.0.0.1'::inet NOT NULL ); @@ -6636,4 +6637,6 @@ INSERT INTO schema_migrations (version) VALUES ('20131228230219'); INSERT INTO schema_migrations (version) VALUES ('20140111191413'); -INSERT INTO schema_migrations (version) VALUES ('20140204233337'); \ No newline at end of file +INSERT INTO schema_migrations (version) VALUES ('20140204233337'); + +INSERT INTO schema_migrations (version) VALUES ('20140221213349'); \ No newline at end of file