notificationcomments

This commit is contained in:
yanxd 2014-06-07 10:45:57 +08:00
parent 45e12c4bef
commit c3865ab319
4 changed files with 9 additions and 8 deletions

View File

@ -8,14 +8,14 @@ class NotificationcommentsController < ApplicationController
@contest = Contest.find(params[:contest_id])
@contestnotification = Contestnotification.find(params[:contestnotification_id])
@notificaioncomment = Notificationcomment.new
@notificaioncomment.safe_attributes = params[:notificaioncomment]
@notificaioncomment.author = User.current
if @contestnotification.notificationcomments << @notificaioncomment
flash[:notice] = l(:label_comment_added)
# @notificaioncomment = Notificationcomment.new
# @notificaioncomment.safe_attributes = params[:notificationcomment]
# @notificaioncomment.author = User.current
comment = @contestnotification.notificationcomments.new(params[:notificationcomment].merge(author_id: User.current.id))
if comment.save
flash[:notice] = l(:label_comment_added)
end
#redirect_to contest_contestnotification_notificationcomment_path(@contest, @contestnotification, @notificaioncomment)
redirect_to contest_contestnotification_path(@contest, @contestnotification)
end

View File

@ -5,7 +5,7 @@ class Contestnotification < ActiveRecord::Base
#Contestnotification::Notificationcomment
belongs_to :contest
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
has_many :notificationcomments, :dependent => :delete_all, :order => "created_at"
has_many :notificationcomments, as: :notificationcommented, :dependent => :delete_all, :order => "created_at"
# fq
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy

View File

@ -2,6 +2,6 @@
<%= labelled_form_for @contestnotification, :url => contest_contestnotifications_path(@contest), :html => { :id => 'contestnotifications-form', :multipart => true } do |f| %>
<%= render :partial => 'contestnotifications/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
<%= preview_link preview_contestnotifications_path(:contest_id => @contest), 'contestnotifications-form' ,target='preview',{:class => 'whiteButton m3p10'}%>
<%= preview_link preview_contest_contestnotifications_path(:contest_id => @contest), 'contestnotifications-form' ,target='preview',{:class => 'whiteButton m3p10'}%>
<% end %>
<div id="preview" class="wiki"></div>

View File

@ -77,6 +77,7 @@ RedmineApp::Application.routes.draw do
## new added by linchun #新竞赛相关
resources :contests, only: [:index] do
resources :contestnotifications do
get 'preview', on: :collection
resources :notificationcomments
end