Skip to content
Snippets Groups Projects
Commit 18b1f171 authored by Marin Jankovski's avatar Marin Jankovski
Browse files

Rename snippets scopes to plural names.

parent 84dc9cd6
Branches
Tags
No related merge requests found
Loading
@@ -14,7 +14,7 @@ class SnippetsController < ApplicationController
Loading
@@ -14,7 +14,7 @@ class SnippetsController < ApplicationController
layout 'navless' layout 'navless'
   
def index def index
@snippets = Snippet.is_public.fresh.non_expired.page(params[:page]).per(20) @snippets = Snippet.are_public.fresh.non_expired.page(params[:page]).per(20)
end end
   
def user_index def user_index
Loading
@@ -26,15 +26,15 @@ class SnippetsController < ApplicationController
Loading
@@ -26,15 +26,15 @@ class SnippetsController < ApplicationController
   
if @user == current_user if @user == current_user
@snippets = case params[:scope] @snippets = case params[:scope]
when 'is_public' then when 'are_public' then
@snippets.is_public @snippets.are_public
when 'is_private' then when 'are_private' then
@snippets.is_private @snippets.are_private
else else
@snippets @snippets
end end
else else
@snippets = @snippets.is_public @snippets = @snippets.are_public
end end
   
@snippets = @snippets.page(params[:page]).per(20) @snippets = @snippets.page(params[:page]).per(20)
Loading
Loading
Loading
@@ -34,8 +34,8 @@ class Snippet < ActiveRecord::Base
Loading
@@ -34,8 +34,8 @@ class Snippet < ActiveRecord::Base
validates :content, presence: true validates :content, presence: true
   
# Scopes # Scopes
scope :is_public, -> { where(private: false) } scope :are_public, -> { where(private: false) }
scope :is_private, -> { where(private: true) } scope :are_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]) }
Loading
Loading
Loading
@@ -18,16 +18,16 @@
Loading
@@ -18,16 +18,16 @@
All All
%span.pull-right %span.pull-right
= @user.snippets.count = @user.snippets.count
= nav_tab :scope, 'is_private' do = nav_tab :scope, 'are_private' do
= link_to user_snippets_path(@user, scope: 'is_private') do = link_to user_snippets_path(@user, scope: 'are_private') do
Private Private
%span.pull-right %span.pull-right
= @user.snippets.is_private.count = @user.snippets.are_private.count
= nav_tab :scope, 'is_public' do = nav_tab :scope, 'are_public' do
= link_to user_snippets_path(@user, scope: 'is_public') do = link_to user_snippets_path(@user, scope: 'are_public') do
Public Public
%span.pull-right %span.pull-right
= @user.snippets.is_public.count = @user.snippets.are_public.count
   
.col-md-9.my-snippets .col-md-9.my-snippets
= render 'snippets' = render 'snippets'
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment