From 9324d45e2cd74e6d8c82c4551df3cea646a3e63d Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Sep 2015 16:23:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E6=B7=BB=E5=8A=A0=E6=A0=87=E9=A2=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/system_messages_controller.rb | 1 + app/models/system_message.rb | 5 +++-- app/views/admin/messages.html.erb | 3 +++ db/migrate/20150917081214_add_subject_to_system_message.rb | 5 +++++ db/schema.rb | 3 ++- 5 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20150917081214_add_subject_to_system_message.rb diff --git a/app/controllers/system_messages_controller.rb b/app/controllers/system_messages_controller.rb index 76fa99e32..66ec6c2d7 100644 --- a/app/controllers/system_messages_controller.rb +++ b/app/controllers/system_messages_controller.rb @@ -39,6 +39,7 @@ class SystemMessagesController < ApplicationController end @system_messages = SystemMessage.new @system_messages.description = params[:system_message][:description] + @system_messages.subject = params[:system_message][:subject] @system_messages.user_id = User.current.id respond_to do |format| if @system_messages.save diff --git a/app/models/system_message.rb b/app/models/system_message.rb index 3430bea5f..2a810e8b8 100644 --- a/app/models/system_message.rb +++ b/app/models/system_message.rb @@ -1,7 +1,8 @@ class SystemMessage < ActiveRecord::Base - attr_accessible :content, :id, :user_id, :description + attr_accessible :content, :id, :user_id, :description, :subject belongs_to :user - validates :description, presence: true + validates :subject, presence: true + # validates :description, presence: true validates_length_of :description, maximum: 10000 end diff --git a/app/views/admin/messages.html.erb b/app/views/admin/messages.html.erb index 26a54d647..5e49822ad 100644 --- a/app/views/admin/messages.html.erb +++ b/app/views/admin/messages.html.erb @@ -4,6 +4,9 @@
<%= form_for(@admin_messages, :html => {:id =>'system_messages-form'}) do |f| %> +
+ <%= f.text_area :subject %> +
<%= f.kindeditor :description,:width=>'87%',:editor_id=>'system_message_editor' %>

diff --git a/db/migrate/20150917081214_add_subject_to_system_message.rb b/db/migrate/20150917081214_add_subject_to_system_message.rb new file mode 100644 index 000000000..69cdd2a63 --- /dev/null +++ b/db/migrate/20150917081214_add_subject_to_system_message.rb @@ -0,0 +1,5 @@ +class AddSubjectToSystemMessage < ActiveRecord::Migration + def change + add_column :system_messages, :subject, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 5eec29135..7d8678753 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150915063302) do +ActiveRecord::Schema.define(:version => 20150917081214) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1365,6 +1365,7 @@ ActiveRecord::Schema.define(:version => 20150915063302) do t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.text "description" + t.string "subject" end create_table "taggings", :force => true do |t|