Commit 35f39301a115c13d3986b27310bd4943f8700959
1 parent
31889891
Exists in
master
and in
22 other branches
view-page: fix comment references
Showing
2 changed files
with
11 additions
and
9 deletions
Show diff stats
app/views/comment/_comment_form.html.erb
| ... | ... | @@ -46,14 +46,16 @@ function check_captcha(button, confirm_action) { |
| 46 | 46 | } |
| 47 | 47 | </script> |
| 48 | 48 | |
| 49 | -<% if @comment && @comment.errors.any? %> | |
| 49 | +<% @comment ||= Comment.new %> | |
| 50 | + | |
| 51 | +<% if @comment.errors.any? %> | |
| 50 | 52 | <%= error_messages_for :comment %> |
| 51 | 53 | <% end %> |
| 52 | 54 | |
| 53 | 55 | <div class="post_comment_box <%= ((defined? show_form) && show_form) ? 'opened' : 'closed' %>"> |
| 54 | 56 | |
| 55 | 57 | <%= link_to(_('Post a comment'), '#', :class => 'display-comment-form') if display_link && @comment.reply_of_id.blank? %> |
| 56 | -<%= remote_form_for(:comment, comment, :url => {:profile => profile.identifier, :controller => 'comment', :action => (edition_mode ? 'update' : 'create'), :id => (edition_mode ? comment.id : @page.id)}, :html => { :class => 'comment_form' } ) do |f| %> | |
| 58 | +<%= remote_form_for(:comment, @comment, :url => {:profile => profile.identifier, :controller => 'comment', :action => (edition_mode ? 'update' : 'create'), :id => (edition_mode ? @comment.id : @page.id)}, :html => { :class => 'comment_form' } ) do |f| %> | |
| 57 | 59 | |
| 58 | 60 | <%= required_fields_message %> |
| 59 | 61 | ... | ... |
app/views/content_viewer/view_page.html.erb
| ... | ... | @@ -80,7 +80,7 @@ |
| 80 | 80 | </h3> |
| 81 | 81 | <% end %> |
| 82 | 82 | |
| 83 | - <% if @page.accept_comments? && @comments.count > 1 %> | |
| 83 | + <% if @page.accept_comments? && @comments.present? && @comments.count > 1 %> | |
| 84 | 84 | <%= link_to(_('Post a comment'), '#', :class => 'display-comment-form', :id => 'top-post-comment-button', :onclick => "jQuery('#page-comment-form .display-comment-form').first().click();") %> |
| 85 | 85 | |
| 86 | 86 | <%= hidden_field_tag("page_url", url_for(:controller=>'content_viewer', :action=>'view_page', :profile=>profile.identifier, :page => @page.explode_path)) %> |
| ... | ... | @@ -90,15 +90,15 @@ |
| 90 | 90 | <%= select_tag 'comment_order', options_for_select({_('Oldest first')=>'oldest', _('Newest first')=>'newest'}, @comment_order) %> |
| 91 | 91 | <% end %> |
| 92 | 92 | </div> |
| 93 | - <% end %> | |
| 94 | 93 | |
| 95 | - <ul class="article-comments-list"> | |
| 96 | - <%= render :partial => 'comment/comment', :collection => @comments %> | |
| 97 | - <%= pagination_links @comments, :param_name => 'comment_page' %> | |
| 98 | - </ul> | |
| 94 | + <ul class="article-comments-list"> | |
| 95 | + <%= render :partial => 'comment/comment', :collection => @comments %> | |
| 96 | + <%= pagination_links @comments, :param_name => 'comment_page' %> | |
| 97 | + </ul> | |
| 98 | + <% end %> | |
| 99 | 99 | |
| 100 | 100 | <% if @page.accept_comments? %> |
| 101 | - <div id='page-comment-form' class='page-comment-form'><%= render :partial => 'comment/comment_form', :locals =>{:comment => Comment.new, :url => {:controller => :comment, :action => :create}, :display_link => true, :cancel_triggers_hide => true}%></div> | |
| 101 | + <div id='page-comment-form' class='page-comment-form'><%= render :partial => 'comment/comment_form', :locals =>{:url => {:controller => :comment, :action => :create}, :display_link => true, :cancel_triggers_hide => true}%></div> | |
| 102 | 102 | <% end %> |
| 103 | 103 | </div><!-- end class="comments" --> |
| 104 | 104 | ... | ... |