Create first comment automatically from the annotation
This commit is contained in:
@@ -13,6 +13,12 @@ class Legislation::Annotation < ActiveRecord::Base
|
||||
validates :draft_version, presence: true
|
||||
validates :author, presence: true
|
||||
|
||||
after_create :create_first_comment
|
||||
|
||||
def create_first_comment
|
||||
comments.create(body: self.text, user: self.author)
|
||||
end
|
||||
|
||||
def title
|
||||
text[0..50]
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<%= annotation.quote %>
|
||||
</div>
|
||||
<%= link_to legislation_process_draft_version_annotation_path(@process, @draft_version, annotation) do %>
|
||||
<span class="icon-comments" aria-hidden="true"></span> <span><%= t('.comments_count', count: annotation.comments_count + 1) %></span></a>
|
||||
<span class="icon-comments" aria-hidden="true"></span> <span><%= t('.comments_count', count: annotation.comments_count) %></span></a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -27,12 +27,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 medium-10 column legislation-comment">
|
||||
<%= @annotation.text %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render 'comments', commentable: @annotation %>
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user