Commit 90c2e0d9 authored by Marin Jankovski's avatar Marin Jankovski

Replace now forbidden keywords public and private for snippets scope

parent 51d5e4cd
...@@ -14,7 +14,7 @@ class SnippetsController < ApplicationController ...@@ -14,7 +14,7 @@ class SnippetsController < ApplicationController
layout 'navless' layout 'navless'
def index def index
@snippets = Snippet.public.fresh.non_expired.page(params[:page]).per(20) @snippets = Snippet.is_public.fresh.non_expired.page(params[:page]).per(20)
end end
def user_index def user_index
......
...@@ -34,8 +34,8 @@ class Snippet < ActiveRecord::Base ...@@ -34,8 +34,8 @@ class Snippet < ActiveRecord::Base
validates :content, presence: true validates :content, presence: true
# Scopes # Scopes
scope :public, -> { where(private: false) } scope :is_public, -> { where(private: false) }
scope :private, -> { where(private: true) } scope :is_private, -> { where(private: true) }
scope :fresh, -> { order("created_at DESC") } scope :fresh, -> { order("created_at DESC") }
scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) } scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) }
scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) } scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment