Commit 18b1f171bd0b9700e73c37c23150bea9fb251b3e

Authored by Marin Jankovski
1 parent 84dc9cd6

Rename snippets scopes to plural names.

app/controllers/snippets_controller.rb
... ... @@ -14,7 +14,7 @@ class SnippetsController < ApplicationController
14 14 layout 'navless'
15 15  
16 16 def index
17   - @snippets = Snippet.is_public.fresh.non_expired.page(params[:page]).per(20)
  17 + @snippets = Snippet.are_public.fresh.non_expired.page(params[:page]).per(20)
18 18 end
19 19  
20 20 def user_index
... ... @@ -26,15 +26,15 @@ class SnippetsController < ApplicationController
26 26  
27 27 if @user == current_user
28 28 @snippets = case params[:scope]
29   - when 'is_public' then
30   - @snippets.is_public
31   - when 'is_private' then
32   - @snippets.is_private
  29 + when 'are_public' then
  30 + @snippets.are_public
  31 + when 'are_private' then
  32 + @snippets.are_private
33 33 else
34 34 @snippets
35 35 end
36 36 else
37   - @snippets = @snippets.is_public
  37 + @snippets = @snippets.are_public
38 38 end
39 39  
40 40 @snippets = @snippets.page(params[:page]).per(20)
... ...
app/models/snippet.rb
... ... @@ -34,8 +34,8 @@ class Snippet < ActiveRecord::Base
34 34 validates :content, presence: true
35 35  
36 36 # Scopes
37   - scope :is_public, -> { where(private: false) }
38   - scope :is_private, -> { where(private: true) }
  37 + scope :are_public, -> { where(private: false) }
  38 + scope :are_private, -> { where(private: true) }
39 39 scope :fresh, -> { order("created_at DESC") }
40 40 scope :expired, -> { where(["expires_at IS NOT NULL AND expires_at < ?", Time.current]) }
41 41 scope :non_expired, -> { where(["expires_at IS NULL OR expires_at > ?", Time.current]) }
... ...
app/views/snippets/current_user_index.html.haml
... ... @@ -18,16 +18,16 @@
18 18 All
19 19 %span.pull-right
20 20 = @user.snippets.count
21   - = nav_tab :scope, 'is_private' do
22   - = link_to user_snippets_path(@user, scope: 'is_private') do
  21 + = nav_tab :scope, 'are_private' do
  22 + = link_to user_snippets_path(@user, scope: 'are_private') do
23 23 Private
24 24 %span.pull-right
25   - = @user.snippets.is_private.count
26   - = nav_tab :scope, 'is_public' do
27   - = link_to user_snippets_path(@user, scope: 'is_public') do
  25 + = @user.snippets.are_private.count
  26 + = nav_tab :scope, 'are_public' do
  27 + = link_to user_snippets_path(@user, scope: 'are_public') do
28 28 Public
29 29 %span.pull-right
30   - = @user.snippets.is_public.count
  30 + = @user.snippets.are_public.count
31 31  
32 32 .col-md-9.my-snippets
33 33 = render 'snippets'
... ...
config/initializers/state_machine_patch.rb
... ... @@ -2,8 +2,8 @@
2 2 # where gem 'state_machine' was not working for Rails 4.1
3 3 module StateMachine
4 4 module Integrations
5   - module ActiveModel
6   - public :around_validation
7   - end
  5 + module ActiveModel
  6 + public :around_validation
  7 + end
8 8 end
9 9 end
... ...