Class CommentsController
In: app/controllers/comments_controller.rb
Parent: ApplicationController

Methods

create   new   show  

Public Instance methods

[Source]

     # File app/controllers/comments_controller.rb, line 36
 36:   def create
 37:     @from_blog = (params[:from_blog] == "true" ? true : false)
 38:     if params[:perma_link]
 39:       @link = Link.new_from_s(params[:perma_link])
 40:       @link.resolve
 41: 
 42:       if !@link.to_logi
 43:         @link.errors.add(:link, t('c.comments.error_specific_logi'))
 44:       end
 45: 
 46:       if @link.errors.empty?
 47:           self.thorny_form_free_of_spam?
 48:         @commenting = Commenting.new(:from_logi => @logi,
 49:             :to_logi => @link.volatile_to_logi, :user => current_user)
 50:         @commenting.save
 51: 
 52:         flash[:notice] = t('c.comments.added_commenting_logi',
 53:             :logi => @link.volatile_to_logi.to_s(:for => :full_show))
 54:         render :update do |page|
 55:           page.redirect_to logi_ll_url(@logi)
 56:         end
 57:       else
 58:         transfer_errors(@link, @logi, :attribute => :comment_link)
 59:         flash.now[:error] = t 'c.comments.error_connecting'
 60:         @selected = 'existing_logi'
 61:       end
 62:     elsif @from_blog
 63:       @commenting_logi, @commenting_logi_version = self.create_logi(
 64:           params[:logi].merge({
 65:               :link_string => (current_user.home_page_tag_string + 
 66:                   '/' + Tag.blog.to_s)}))
 67: 
 68:       transfer_errors(@commenting_logi, @logi)
 69: 
 70:       if @logi.errors.empty? and @commenting_logi_version.valid? and 
 71:           self.thorny_form_free_of_spam?
 72:         @commenting_logi.save
 73: 
 74:         flash[:notice] = t 'c.logis.created',
 75:             :logi => @commenting_logi.to_s(:for => :full_show)
 76: 
 77:         render :update do |page|
 78:           page.redirect_to logi_ll_url(@logi)
 79:         end
 80:       else
 81:         transfer_errors(@commenting_logi_version, @logi_version)
 82: 
 83:         flash.now[:error] = t 'c.comments.error_creating'
 84:         @selected = 'new_logi'
 85:       end
 86:     else # new logi
 87:       @commenting_logi, @commenting_logi_version = self.create_logi(
 88:           params[:logi], :untagged => :if_unset)
 89:       @commenting = Commenting.new(:from_logi => @logi,
 90:           :to_logi => @commenting_logi, :user => current_user)
 91: 
 92:       transfer_errors(@commenting_logi, @logi)
 93: 
 94:       if @logi.errors.empty? and @commenting_logi_version.valid? and 
 95:           @commenting.valid? and self.thorny_form_free_of_spam?
 96:         # we can save as we know the link is valid on the logi
 97:         @commenting_logi.save
 98:         @commenting.save
 99: 
100:         flash[:notice] = t 'c.comments.created_commenting_logi',
101:             :logi => @commenting_logi.to_s(:for => :full_show)
102: 
103:         render :update do |page|
104:           page.redirect_to logi_ll_url(@logi)
105:         end
106:       else
107:         transfer_errors(@commenting_logi_version, @logi_version)
108: 
109:         flash.now[:error] = t 'c.comments.error_creating'
110:         @selected = 'new_logi'
111:       end
112:     end
113:   end

REST-methods

[Source]

    # File app/controllers/comments_controller.rb, line 24
24:   def new
25:     @from_blog = (params[:from_blog] == "true" ? true : false)
26:     @selected = params[:selected] || 'new_logi'
27:     @commenting_logi = Logi.new_with(:creator => current_user,
28:         :user_group => current_prefs.user_group)
29:     @commenting_logi_version = @commenting_logi.current_logi_version
30:     render :partial => 'new.html.erb', :locals => {
31:         :selected => @selected}
32:   end
show()

Alias for new

[Validate]