Class: Muck::CommentsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Muck::CommentsController
- Defined in:
- app/controllers/muck/comments_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/muck/comments_controller.rb', line 34 def create @comment = @parent.comments.build(params[:comment]) @comment.user = current_user @comment.save! = t('muck.comments.create_success') handle_after_create(true, ) rescue ActiveRecord::RecordInvalid => ex if @comment errors = @comment.errors..to_sentence else errors = ex end = t('muck.comments.create_error', :errors => errors) handle_after_create(false, ) end |
#destroy ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/muck/comments_controller.rb', line 50 def destroy @comment.destroy respond_to do |format| format.html do flash[:notice] = t('muck.comments.comment_removed') redirect_back_or_default(current_user) end format.js { render :text => "jQuery('##{@comment.dom_id}').fadeOut();" } format.json { render :json => { :success => true, :message => t("muck.comments.comment_removed"), :comment_id => @comment.id } } end end |
#index ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/muck/comments_controller.rb', line 7 def index @parent = get_parent @comment = Comment.find(params[:id]) rescue nil @comments = @parent.comments.by_newest if !@parent.blank? @comments ||= @comment.children if !@comment.blank? #@comments ||= Comment.by_newest respond_to do |format| format.html { render :template => 'comments/index', :layout => 'popup' } format.pjs { render :template => 'comments/index', :layout => false } end end |
#new ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/muck/comments_controller.rb', line 20 def new title = @parent.title rescue '' title ||= @parent.name rescue '' if title.blank? @page_title = t('muck.comments.new_comment_no_title') else @page_title = t('muck.comments.new_comment_with_title', :title => title) end respond_to do |format| format.html { render :template => 'comments/new', :layout => 'popup' } format.pjs { render :template => 'comments/new', :layout => false } end end |