Sha256: 1a38bc9c28d71881981eb3461e477cbf961a79538f8ce7589b1a74878a98481f
Contents?: true
Size: 1.42 KB
Versions: 8
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true module C class Blog < ApplicationRecord include SitePage include Imageable include Previewable include Authorable scope :ordered, -> { order created_at: :desc } validates :name, presence: true def self.created_in_date_range(start_date, end_date, options = {}) limit = options.delete(:limit) Blog.where(created_at: start_date...end_date).limit(limit) end def self.created_in_month(options = {}) year = options[:year] || Time.now.year month = options[:month] || Time.now.month limit = options[:limit] date_start = Time.new(year, month, 1, 0, 0, 0) date_end = date_start.advance(months: 1) created_in_date_range(date_start, date_end, limit: limit) end def self.created_in_year(options = {}) year = options[:year] || Time.now.year limit = options[:limit] date_start = Time.new(year, 1, 1, 0, 0, 0) date_end = date_start.advance(years: 1) created_in_date_range(date_start, date_end, limit: limit) end INDEX_TABLE = { "Name": { link: { name: { call: 'name' }, options: '[:edit, object]' }, sort: 'name' }, "Author": { call: 'author', sort: 'author' }, "Published": { call: 'published', sort: 'published' }, "Created": { call: 'created_at', sort: 'published' }, "Edit": { link: { name: { text: 'edit' }, options: '[:edit, object]' } } }.freeze end end
Version data entries
8 entries across 8 versions & 1 rubygems