diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 4589464ef..08c0505e0 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -282,6 +282,19 @@ class ForumsController < ApplicationController end end + # 更新贴吧描述 + def update_memo_description + @forum = Forum.find(params[:id]) + if @forum.blank? + result = { :result => false } + else + forum_decription = params[:forum][:description] + @forum.update_attributes(:description => forum_decription ) + result = { :result => true } + end + render :json => result + end + def search_forum # @forums = paginateHelper Forum.where("name LIKE '%#{params[:name]}%'") q = "%#{params[:name].strip}%" diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 0d7b62596..25b12e52a 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -1,6 +1,6 @@ class MemosController < ApplicationController default_search_scope :memos - before_filter :find_forum, :only => [:new, :create, :preview] + before_filter :find_forum, :only => [:new, :create, :preview, :update] before_filter :find_attachments, :only => [:preview] before_filter :find_memo, :except => [:new, :create, :preview] before_filter :authenticate_user_edit, :only => [:edit, :update] @@ -47,7 +47,7 @@ class MemosController < ApplicationController end @memo = Memo.new(params[:memo]) - @memo.forum_id = params[:forum_id] + @memo.forum_id = @forum.id @memo.author_id = User.current.id if params[:memo][:parent_id] @@ -154,6 +154,8 @@ class MemosController < ApplicationController end def update + # 注意,如果不需要 + @flag = false respond_to do |format| if( #@memo.update_column(:subject, params[:memo][:subject]) && @@ -163,10 +165,11 @@ class MemosController < ApplicationController @memo.update_column(:subject,params[:memo][:subject]) && @memo.update_column(:updated_at,Time.now)) @memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads])) + @memo.forum_id = @forum.id @flag = @memo.save # @memo.root.update_attribute(:updated_at, @memo.updated_at) format.js - format.html {redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}"} + format.html {redirect_to back_memo_url, notice: "#{l :label_memo_update_succ}"} else format.js format.html { render action: "edit" } diff --git a/app/views/forums/_form.html.erb b/app/views/forums/_form.html.erb index 35d202a79..cc2037e75 100644 --- a/app/views/forums/_form.html.erb +++ b/app/views/forums/_form.html.erb @@ -2,7 +2,7 @@