Sha256: 8c9b0e64f348c92d2236d2084d3aeb545419afab8da28f6c5bda79c7024c0be8

Contents?: true

Size: 928 Bytes

Versions: 4

Compression:

Stored size: 928 Bytes

Contents

module Ramaze
  #:nodoc:
  module Helper
    ##
    # Helper used by the comments package.
    #
    # @since  0.2.8
    #
    module Comment
      ##
      # Given a comment ID this method checks if that ID results in a valid
      # instance of Comments::Model::Comment. If this is the case the object is
      # returned, otherwise the user is redirected back to the comment overview
      # and is shown a message.
      #
      # @since  0.2.8
      # @param  [Fixnum] comment_id The ID of the comment to validate.
      # @return [Comments::Model::Comment]
      #
      def validate_comment(comment_id)
        comment = ::Comments::Model::Comment[comment_id]

        if comment.nil?
          message(:error, lang('comments.errors.invalid_comment'))
          redirect(::Comments::Controller::Comments.r(:index))
        else
          return comment
        end
      end
    end # Comment
  end # Helper
end # Ramaze

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zen-0.4 lib/zen/package/comments/lib/comments/helper/comment.rb
zen-0.3 lib/zen/package/comments/lib/comments/helper/comment.rb
zen-0.3b1 lib/zen/package/comments/lib/comments/helper/comment.rb
zen-0.3b lib/zen/package/comments/lib/comments/helper/comment.rb