Class: Admin::CommentsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Admin::CommentsController
- Defined in:
- lib/generators/open_loam/install/templates/admin/comments_controller.rb
Overview
One controller for every commentable entity, because a comment form is the same form whatever it is attached to.
Create only: comments are a record of what was said, so there is no edit and no delete here.
Constant Summary
Constants included from Pagination
Instance Method Summary collapse
Methods inherited from BaseController
Methods included from Pagination
Instance Method Details
#create ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/generators/open_loam/install/templates/admin/comments_controller.rb', line 8 def create record = commentable # Commenting is open to any member — and membership is already proven: # BaseController refuses the request otherwise. The policy check is the # record's own, so an entity that hides itself from a role hides its # discussion too. (policy_for(record), :read?) comment = record.open_loam_comments.new(body: params[:body], author: current_actor) flash[:alert] = comment.errors..to_sentence unless comment.save redirect_back fallback_location: [ :admin, record ] end |