From 4a7d3c90727b4d1f9c1617379a767c4c1b040819 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 14 Sep 2015 15:33:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=95=BF=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/system_messages_controller.rb | 4 ++-- app/models/system_message.rb | 6 +++--- app/views/admin/messages.html.erb | 4 ++-- app/views/users/user_messages.html.erb | 8 ++++---- .../20150914063751_add_description_to_system_message.rb | 5 +++++ db/schema.rb | 7 ++++--- 6 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 db/migrate/20150914063751_add_description_to_system_message.rb diff --git a/app/controllers/system_messages_controller.rb b/app/controllers/system_messages_controller.rb index 42291a407..5ba04241c 100644 --- a/app/controllers/system_messages_controller.rb +++ b/app/controllers/system_messages_controller.rb @@ -38,14 +38,14 @@ class SystemMessagesController < ApplicationController return end @system_messages = SystemMessage.new - @system_messages.content = params[:system_message][:content] + @system_messages.description = params[:system_message][:description] @system_messages.user_id = User.current.id respond_to do |format| if @system_messages.save format.html {redirect_to user_message_path(User.current, :type => "system_messages")} flash[:notice] = l(:notice_successful_message) else - if params[:system_message][:content].empty? + if params[:system_message][:description].empty? flash[:error] = l(:label_content_blank_fail) else flash[:error] = l(:label_admin_message_fail) diff --git a/app/models/system_message.rb b/app/models/system_message.rb index 92a989cb3..3430bea5f 100644 --- a/app/models/system_message.rb +++ b/app/models/system_message.rb @@ -1,7 +1,7 @@ class SystemMessage < ActiveRecord::Base - attr_accessible :content, :id, :user_id + attr_accessible :content, :id, :user_id, :description belongs_to :user - validates :content, presence: true - validates_length_of :content, maximum: 255 + 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 10169f30b..cd28b09a8 100644 --- a/app/views/admin/messages.html.erb +++ b/app/views/admin/messages.html.erb @@ -5,7 +5,7 @@
<%= form_for(@admin_messages, :html => {:id =>'system_message-form'}) do |f| %>
- <%= f.kindeditor :content,:width=>'87%',:editor_id=>'system_message_editor' %> + <%= f.kindeditor :description,:width=>'87%',:editor_id=>'system_message_editor' %>

@@ -25,7 +25,7 @@ $("#content_notice_span").focus(); return false; } - else if (obj.length > 255) { + else if (obj.length > 10000) { $("#content_notice_span").text("内容过长,超过255个字符"); $("#content_notice_span").css('color', '#ff0000'); $("#content_notice_span").focus(); diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index a9fb0ffbd..b713c7152 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -56,14 +56,14 @@ Trustie平台发布新消息:
  • - <%= link_to usm.content.html_safe, user_message_path(User.current, :type => "system_messages"), + <%= link_to usm.content.nil? ? usm.description.html_safe : usm.content.html_safe, user_message_path(User.current, :type => "system_messages"), :class => "newsRed", :onmouseover => "message_titile_show($(this),event);", :onmouseout => "message_titile_hide($(this));" %>
  • <%= time_tag(usm.created_at).html_safe %>
  • @@ -350,14 +350,14 @@
  • Trustie平台发布新消息:
  • - <%= link_to ma.content.html_safe, user_message_path(User.current, :type => "system_messages"), + <%= link_to ma.content.nil? ? ma.description.html_safe : ma.content.html_safe, user_message_path(User.current, :type => "system_messages"), :class => "#{params[:type]=="unviewed" ? "newsBlack" : "newsRed"}", :onmouseover =>"message_titile_show($(this),event);", :onmouseout => "message_titile_hide($(this));" %>
  • <%= time_tag(ma.created_at).html_safe %>
  • diff --git a/db/migrate/20150914063751_add_description_to_system_message.rb b/db/migrate/20150914063751_add_description_to_system_message.rb new file mode 100644 index 000000000..9cc9e4172 --- /dev/null +++ b/db/migrate/20150914063751_add_description_to_system_message.rb @@ -0,0 +1,5 @@ +class AddDescriptionToSystemMessage < ActiveRecord::Migration + def change + add_column :system_messages, :description, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 6bc43fe5c..b162337d3 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 => 20150909062619) do +ActiveRecord::Schema.define(:version => 20150914063751) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1361,8 +1361,9 @@ ActiveRecord::Schema.define(:version => 20150909062619) do create_table "system_messages", :force => true do |t| t.integer "user_id" t.string "content" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.text "description" end create_table "taggings", :force => true do |t|