Skip to content
Browse files

SOC-1 #comment fixed comments not being saved bug. issue was related …

…to validation. changed username to user.name
  • Loading branch information...
1 parent 9bb54c3 commit 8a4feaba39fb2b1c21fac757de99e05327a341ab Eric Ryan Jones committed
View
4 app/controllers/comments_controller.rb
@@ -3,8 +3,8 @@ def create
@comment_hash = params[:comment]
@obj = @comment_hash[:commentable_type].constantize.find(@comment_hash[:commentable_id])
# Not implemented: check to see whether the user has permission to create a comment on this object
- @comment = Comment.build_from(@obj, current_user, @comment_hash[:body])
- if @comment.save
+ @comment = Comment.build_from(@obj, current_user.id, @comment_hash[:body])
+ if @comment.save!
render :partial => "comments/comment", :locals => { :comment => @comment }, :layout => false, :status => :created
else
render :js => "alert('error saving comment');"
View
2 app/controllers/topics_controller.rb
@@ -44,7 +44,7 @@ def show
@topic = Topic.find(params[:id])
@comments = @topic.comment_threads.order('created_at desc')
- @new_comment = Comment.build_from(@topic, current_user, "")
+ @new_comment = Comment.build_from(@topic, current_user.id, "")
end
end
View
2 app/views/comments/_comment.html.erb
@@ -1,7 +1,7 @@
<div class="comment" id="comment-#{comment.id}">
<hr>
<%= link_to "×", comment_path(comment), :method => :delete, :remote => true, :confirm => "Are you sure you want to remove this comment?", :disable_with => "×", :class => 'close' %>
-<h4><%= comment.user.username %></h4>
+<h4><%= comment.user.name %></h4>
<%= comment.updated_at %>
<%= comment.body %>
</div>

0 comments on commit 8a4feab

Please sign in to comment.
Something went wrong with that request. Please try again.