Commit 90c2e0d971b5c105224196b8509012f943c9ea9b
1 parent
51d5e4cd
Exists in
spb-stable
and in
2 other branches
Replace now forbidden keywords public and private for snippets scope
Showing
2 changed files
with
3 additions
and
3 deletions
Show diff stats
app/controllers/snippets_controller.rb
@@ -14,7 +14,7 @@ class SnippetsController < ApplicationController | @@ -14,7 +14,7 @@ class SnippetsController < ApplicationController | ||
14 | layout 'navless' | 14 | layout 'navless' |
15 | 15 | ||
16 | def index | 16 | def index |
17 | - @snippets = Snippet.public.fresh.non_expired.page(params[:page]).per(20) | 17 | + @snippets = Snippet.is_public.fresh.non_expired.page(params[:page]).per(20) |
18 | end | 18 | end |
19 | 19 | ||
20 | def user_index | 20 | def user_index |
app/models/snippet.rb
@@ -34,8 +34,8 @@ class Snippet < ActiveRecord::Base | @@ -34,8 +34,8 @@ class Snippet < ActiveRecord::Base | ||
34 | validates :content, presence: true | 34 | validates :content, presence: true |
35 | 35 | ||
36 | # Scopes | 36 | # Scopes |
37 | - scope :public, -> { where(private: false) } | ||
38 | - scope :private, -> { where(private: true) } | 37 | + scope :is_public, -> { where(private: false) } |
38 | + scope :is_private, -> { where(private: true) } | ||
39 | scope :fresh, -> { order("created_at DESC") } | 39 | scope :fresh, -> { order("created_at DESC") } |
40 | scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) } | 40 | scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) } |
41 | scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) } | 41 | scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) } |