Make diary comment creation work again.
This commit is contained in:
parent
ea294c5a68
commit
57a05a40fc
4 changed files with 13 additions and 9 deletions
|
@ -52,7 +52,7 @@ class DiaryEntryController < ApplicationController
|
|||
|
||||
def comment
|
||||
@entry = DiaryEntry.find(params[:id])
|
||||
@diary_comment = @entry.diary_comments.build(params[:diary_comment])
|
||||
@diary_comment = @entry.comments.build(params[:diary_comment])
|
||||
@diary_comment.user = @user
|
||||
if @diary_comment.save
|
||||
if @diary_comment.user != @entry.user
|
||||
|
|
|
@ -2,12 +2,16 @@ class DiaryEntry < ActiveRecord::Base
|
|||
belongs_to :user
|
||||
belongs_to :language, :foreign_key => 'language_code'
|
||||
|
||||
has_many :diary_comments, :include => :user,
|
||||
:conditions => {
|
||||
:users => { :visible => true },
|
||||
:visible => true
|
||||
},
|
||||
:order => "diary_comments.id"
|
||||
has_many :comments, :class_name => "DiaryComment",
|
||||
:include => :user,
|
||||
:order => "diary_comments.id"
|
||||
has_many :visible_comments, :class_name => "DiaryComment",
|
||||
:include => :user,
|
||||
:conditions => {
|
||||
:users => { :visible => true },
|
||||
:visible => true
|
||||
},
|
||||
:order => "diary_comments.id"
|
||||
|
||||
validates_presence_of :title, :body
|
||||
validates_length_of :title, :within => 1..255
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
|
||||
<%= link_to t('diary_entry.diary_entry.reply_link'), :controller => 'message', :action => 'new', :display_name => diary_entry.user.display_name, :title => "Re: #{diary_entry.title}" %>
|
||||
|
|
||||
<%= link_to t('diary_entry.diary_entry.comment_count', :count => diary_entry.diary_comments.count), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'comments' %>
|
||||
<%= link_to t('diary_entry.diary_entry.comment_count', :count => diary_entry.visible_comments.count), :action => 'view', :display_name => diary_entry.user.display_name, :id => diary_entry.id, :anchor => 'comments' %>
|
||||
<% end %>
|
||||
<% if @user == diary_entry.user %>
|
||||
| <%= link_to t('diary_entry.diary_entry.edit_link'), :action => 'edit', :display_name => @user.display_name, :id => diary_entry.id %>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<a id="comments"></a>
|
||||
|
||||
<%= render :partial => 'diary_comment', :collection => @entry.diary_comments %>
|
||||
<%= render :partial => 'diary_comment', :collection => @entry.visible_comments %>
|
||||
|
||||
<% if @user %>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue