Class: CommentsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- CommentsController
- Defined in:
- app/controllers/comments_controller.rb
Overview
module HotfixForRailsActsAsParanoid
refine Banal::Brainstorm do
Banal::Brainstorm.class_eval do
default_scope lambda { with_deleted }
end
end
end
Instance Method Summary collapse
-
#create ⇒ Object
POST /comments POST /comments.json.
-
#destroy ⇒ Object
DELETE /comments/1 DELETE /comments/1.json.
-
#edit ⇒ Object
GET /comments/1/edit.
-
#index ⇒ Object
GET /comments GET /comments.json.
-
#new ⇒ Object
GET /comments/new.
-
#show ⇒ Object
GET /comments/1 GET /comments/1.json.
-
#update ⇒ Object
PATCH/PUT /comments/1 PATCH/PUT /comments/1.json.
Methods inherited from ApplicationController
Instance Method Details
#create ⇒ Object
POST /comments POST /comments.json
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/comments_controller.rb', line 38 def create ActiveRecord::Base.transaction do Banal::Brainstorm.class_eval do default_scope lambda { with_deleted } end @comment = Comment.new(comment_params) @comment.save! Banal::Brainstorm.class_eval do default_scope lambda { where(paranoid_default_scope) } end redirect_to banal_brainstorms_path end end |
#destroy ⇒ Object
DELETE /comments/1 DELETE /comments/1.json
72 73 74 75 76 77 78 |
# File 'app/controllers/comments_controller.rb', line 72 def destroy @comment.destroy respond_to do |format| format.html { redirect_to comments_url, notice: 'Comment was successfully destroyed.' } format.json { head :no_content } end end |
#edit ⇒ Object
GET /comments/1/edit
32 33 |
# File 'app/controllers/comments_controller.rb', line 32 def edit end |
#index ⇒ Object
GET /comments GET /comments.json
17 18 19 |
# File 'app/controllers/comments_controller.rb', line 17 def index @comments = Comment.all end |
#new ⇒ Object
GET /comments/new
27 28 29 |
# File 'app/controllers/comments_controller.rb', line 27 def new @comment = Comment.new end |
#show ⇒ Object
GET /comments/1 GET /comments/1.json
23 24 |
# File 'app/controllers/comments_controller.rb', line 23 def show end |
#update ⇒ Object
PATCH/PUT /comments/1 PATCH/PUT /comments/1.json
58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/comments_controller.rb', line 58 def update respond_to do |format| if @comment.update(comment_params) format.html { redirect_to @comment, notice: 'Comment was successfully updated.' } format.json { render :show, status: :ok, location: @comment } else format.html { render :edit } format.json { render json: @comment.errors, status: :unprocessable_entity } end end end |