From 11231d0ff9384ac805b52f058612a6ffc915bc46 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 24 Feb 2016 16:01:32 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=A7=A3=E5=86=B3=E7=BB=84=E7=BB=87=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=8A=A5500=E7=9A=84=E9=94=99=E8=AF=AF=EF=BC=9B2.?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=BD=AC=E5=8F=91=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 1 + app/models/forward.rb | 4 ++++ app/views/organizations/setting.html.erb | 5 +++-- db/migrate/20160224032046_create_forwards.rb | 15 +++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 app/models/forward.rb create mode 100644 db/migrate/20160224032046_create_forwards.rb diff --git a/app/models/attachment.rb b/app/models/attachment.rb index ea9ad2cc0..c8aa33760 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -28,6 +28,7 @@ class Attachment < ActiveRecord::Base belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id" # 被ForgeActivity虚拟关联 has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy + has_many :forwards, :as => :from # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy # end diff --git a/app/models/forward.rb b/app/models/forward.rb new file mode 100644 index 000000000..c0dffd5e8 --- /dev/null +++ b/app/models/forward.rb @@ -0,0 +1,4 @@ +class Forward < ActiveRecord::Base + validates_presence_of :from_id, :from_type, :to_id, :to_type + belongs_to :from, :polymorphic => true +end \ No newline at end of file diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index 146e643a0..84ddce252 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -59,9 +59,10 @@
http:// .trustie.net申请 - <% if domain.present? and OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).order("updated_at desc").first.content == domain.subname %> + <% record = OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).order("updated_at desc").first %> + <% if domain.present? and record.present? and record.content == domain.subname %> (已批准) - <% elsif OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).count > 0 %> + <% elsif record %> (您申请了子域名<%= OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).order("updated_at desc").first.content %>,还未批准) <% end %>

diff --git a/db/migrate/20160224032046_create_forwards.rb b/db/migrate/20160224032046_create_forwards.rb new file mode 100644 index 000000000..4404dc300 --- /dev/null +++ b/db/migrate/20160224032046_create_forwards.rb @@ -0,0 +1,15 @@ +class CreateForwards < ActiveRecord::Migration + def up + create_table :forwards do|t| + t.integer :from_id + t.string :from_type + t.integer :to_id + t.string :to_type + t.timestamp :created_at + end + end + + def down + drop_table :forwards + end +end