Class: CommentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- CommentsController
- Defined in:
- app/controllers/comments_controller.rb
Instance Method Summary collapse
- #accept ⇒ Object
- #accepted ⇒ Object
- #block ⇒ Object
- #blocked ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
-
#edit ⇒ Object
comments are shown within a page new comments are created by users from within a page.
- #for_feed ⇒ Object
- #index ⇒ Object
- #pending ⇒ Object
- #update ⇒ Object
Instance Method Details
#accept ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/comments_controller.rb', line 46 def accept @comment = Comment.find params[:id] @comment.status = 'accepted' if @comment.save redirect_to :back, notice: t('comments.moderation.accept.notice') else redirect_to comments_path, warning: t('comments.moderation.accept.warning') end end |
#accepted ⇒ Object
71 72 73 74 |
# File 'app/controllers/comments_controller.rb', line 71 def accepted @comments = Comment.accepted.by_recent.paginate(:page => params[:page], :per_page => 50) switch_to_admin_layout end |
#block ⇒ Object
56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/comments_controller.rb', line 56 def block @comment = Comment.find params[:id] @comment.status = 'blocked' if @comment.save redirect_to :back, notice: t('comments.moderation.block.notice') else redirect_to comments_path, warning: t('comments.moderation.block.warning') end end |
#blocked ⇒ Object
76 77 78 79 |
# File 'app/controllers/comments_controller.rb', line 76 def blocked @comments = Comment.blocked.by_recent.paginate(:page => params[:page], :per_page => 50) switch_to_admin_layout end |
#create ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/comments_controller.rb', line 19 def create @comment = Comment.new(comment_params) @comment. = current_user.id @comment.locale = I18n.locale.to_s @comment.status = 'pending' # translation not done with globalize3 but with locale files upon showing status to user if @comment.save redirect_to @comment.page, notice: t('comments.create.notice') else redirect_to @comment.page, warning: t('comments.create.warning') end end |
#destroy ⇒ Object
40 41 42 43 44 |
# File 'app/controllers/comments_controller.rb', line 40 def destroy @comment = Comment.find(params[:id]) @comment.destroy redirect_to comments_url, notice: t('comments.destroy.notice') end |
#edit ⇒ Object
comments are shown within a page new comments are created by users from within a page
14 15 16 17 |
# File 'app/controllers/comments_controller.rb', line 14 def edit @comment = Comment.find(params[:id]) switch_to_admin_layout end |
#for_feed ⇒ Object
81 82 83 84 85 86 87 |
# File 'app/controllers/comments_controller.rb', line 81 def for_feed @comments = Comment.showable.for_locale(I18n.locale).by_recently_created.limit(50) respond_to do |format| format.html { redirect_to root_path } format.atom end end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/comments_controller.rb', line 6 def index @comments = Comment.by_recent.paginate(:page => params[:page], :per_page => 50) switch_to_admin_layout end |
#pending ⇒ Object
66 67 68 69 |
# File 'app/controllers/comments_controller.rb', line 66 def pending @comments = Comment.pending.by_created.paginate(:page => params[:page], :per_page => 50) switch_to_admin_layout end |
#update ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'app/controllers/comments_controller.rb', line 31 def update @comment = Comment.find(params[:id]) if @comment.update_attributes(comment_params) redirect_to comments_path, notice: t('comments.update.notice') else render action: "edit", warning: t('comments.update.warning'), layout: 'admin' end end |