Sha256: 2ac4764b463a1318a64e8edee4e653352dd335079d7247ca61cb7d9dd5f52cb5
Contents?: true
Size: 894 Bytes
Versions: 5
Compression:
Stored size: 894 Bytes
Contents
## # The Comment model is used for creating and managing comments. # # @since 26-09-2011 # class Comment < Sequel::Model plugin :timestamps, :create => :created_at, :update => :updated_at # A comment can belong to only one post and one user many_to_one :post many_to_one :user ## # Validates a comment before saving it to the database. # # @since 26-09-2011 # def validate validates_presence(:comment) # Comments can either have user ID or a custom name. The user ID is only set # when the user is logged in. unless self.user_id validates_presence(:username) end end ## # Gets the name of the author from either an associated user or the "name" # field. # # @since 26-09-2011 # @return [String] # def username if user and user.username return user.username else return super end end end # Comment
Version data entries
5 entries across 5 versions & 1 rubygems