修改删除留言方法为destroy_jour,以及相关路由,访问action的改变

This commit is contained in:
sw 2014-05-20 09:59:33 +08:00
parent c141501085
commit 4de089250f
5 changed files with 59 additions and 5 deletions

View File

@ -1,4 +1,57 @@
class HomeworkAttachController < ApplicationController
###############################
def index
@homeworks = HomeworkAttach.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @homeworks }
end
end
def create
@homework = HomeworkAttach.new(params[:homework])
respond_to do |format|
if @homework.save
format.html { redirect_to @homework, notice: 'Post was successfully created.' }
format.json { render json: @homework, status: :created, location: @homework }
else
format.html { render action: "new" }
format.json { render json: @homework.errors, status: :unprocessable_entity }
end
end
end
def new
@homework = HomeworkAttach.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @homework }
end
end
def edit
@homework = HomeworkAttach.find(params[:id])
end
def update
@homework = HomeworkAttach.find(params[:id])
respond_to do |format|
if @post.update_attributes(params[:homework])
format.html { redirect_to @homework, notice: 'Homework was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @homework.errors, status: :unprocessable_entity }
end
end
end
def destroy
end
#显示作业信息
def show
@homework = HomeworkAttach.find(params[:id])
@ -24,7 +77,7 @@ class HomeworkAttachController < ApplicationController
end
#删除留言
def destroy
def destroy_jour
@journal_destroyed = JournalsForMessage.delete_message(params[:object_id])
#@homework = HomeworkAttach.find(params[:id])
#@jours = @homework.journals_for_messages.order("created_on DESC")

View File

@ -19,8 +19,8 @@
%>
<% end %>
<% if @user == User.current || User.current.admin? || reply.user.id == User.current.id %>
<%= link_to(l(:label_newfeedback_delete), {:controller => 'homework_attach', :action => 'destroy', :object_id => reply, :user_id => reply.user},
:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %>
<%= link_to(l(:label_newfeedback_delete), {:controller => 'homework_attach', :action => 'destroy_jour', :object_id => reply, :user_id => reply.user},
:remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %>
<% end %>
</span>
</p>

View File

@ -54,8 +54,8 @@
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.name}: '); $('##{ids} textarea') ;return false;"}
%>
<% if journal.user==User.current|| User.current.admin? %>
<%= link_to(l(:label_bid_respond_delete), {:controller => 'homework_attach', :action => 'destroy', :object_id => journal, :user_id => journal.user},
:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %>
<%= link_to(l(:label_bid_respond_delete), {:controller => 'homework_attach', :action => 'destroy_jour', :object_id => journal, :user_id => journal.user},
:remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %>
<% end %>
</span>
</span>

View File

@ -29,6 +29,7 @@ RedmineApp::Application.routes.draw do
collection do
match 'addjours', via: [:get, :post]
match 'add_jour_reply', via: [:get,:post]
match 'destroy_jour', via: [:get,:post]
end
end
resources :open_source_projects do