diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 28561bb0e..a5a92c8f3 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -32,16 +32,17 @@ class HomeworkAttachController < ApplicationController :bid_id => bid_id } - @bid = Bid.find bid_id - @homework_list = @bid.homeworks + #@bid = Bid.find bid_id + #@homework_list = @bid.homeworks @homework = HomeworkAttach.new(options) @homework.save_attachments(params[:attachments]) render_attachment_warning_if_needed(@homework) - respond_to do |format| - if @homework.save - redirect_to project_for_bid_path + if @homework.save + respond_to do |format| + format.html { redirect_to project_for_bid_path @homework.bid } + format.json { head :no_content } end end #end @@ -68,20 +69,22 @@ class HomeworkAttachController < ApplicationController @homework.name = name @homework.description = description #@homework.save_attachments(params[:attachments]) - @homework.save - #@homework.name = params[:name] - #@homework.name = params[:description] - #@homework.save - #@homework.update_attribute(params[:homework]) + if @homework.save + respond_to do |format| + format.html { redirect_to project_for_bid_path @homework.bid } + format.json { head :no_content } + end + end end def destroy @homework = HomeworkAttach.find(params[:id]) - @homework.destroy - #respond_to do |format| - # format.html {render @homework} - # format.json {render json: @homework} - #end + if @homework.destroy + respond_to do |format| + format.html { redirect_to project_for_bid_path @homework.bid } + format.json { head :no_content } + end + end end #显示作业信息 diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 684c68513..b4bae3fbe 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -25,7 +25,7 @@ <% end %> <% display_id = im_watching_student_id? @bid%> <% @homework_list.each do |homework|%> -
<%= image_tag(url_to_avatar(homework.user), :class => "avatar")%> |