Skip to content

Commit

Permalink
Fix dashboard comments problem
Browse files Browse the repository at this point in the history
  • Loading branch information
johnf committed Jan 18, 2024
1 parent 37cd70f commit fd88ee8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Do we need dotenv rails?
* Add everything needed to search_params
* The item clause builder should probably use solr and not sql
* language.retired to language.retired?
* Fix comments so they are ajax again

# CRON
paper-trail can we move to JSON serialzer
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
class CommentsController < ApplicationController
load_and_authorize_resource :except => :create

respond_to :js
# respond_to :js

def create
resource = params[:commentable_type].constantize.find(params[:commentable_id])
@comment = resource.comments.build(params[:comment])
@comment = resource.comments.build(comment_params)
authorize! :create, @comment
@comment.owner = current_user
if @comment.save
Expand All @@ -14,7 +14,7 @@ def create
flash[:error] = 'Error while sending the comment.'
end

respond_with @comment
redirect_to [@comment.commentable.collection, @comment.commentable]
end

def destroy
Expand Down
2 changes: 1 addition & 1 deletion app/views/comments/_new.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#new_comment
- if current_user
%h4 Add Comment
= form_for Comment.new, :remote => true do |f|
= form_for Comment.new do |f|
%table.form
%tr
%th= f.label :body, item.class.base_class.name.to_s
Expand Down
2 changes: 1 addition & 1 deletion app/views/page/dashboard.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
- else
- @comments_left.each do |comment|
%tr
%td= link_to comment.commentable.full_identifier, comment.commentable
%td= link_to comment.commentable.full_identifier, [comment.commentable.collection, comment.commentable]
%td= comment.owner_name
%td= comment.body

Expand Down

0 comments on commit fd88ee8

Please sign in to comment.