Commit 18b1f171bd0b9700e73c37c23150bea9fb251b3e
1 parent
84dc9cd6
Exists in
spb-stable
and in
2 other branches
Rename snippets scopes to plural names.
Showing
4 changed files
with
17 additions
and
17 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.is_public.fresh.non_expired.page(params[:page]).per(20) | 17 | + @snippets = Snippet.are_public.fresh.non_expired.page(params[:page]).per(20) |
18 | end | 18 | end |
19 | 19 | ||
20 | def user_index | 20 | def user_index |
@@ -26,15 +26,15 @@ class SnippetsController < ApplicationController | @@ -26,15 +26,15 @@ class SnippetsController < ApplicationController | ||
26 | 26 | ||
27 | if @user == current_user | 27 | if @user == current_user |
28 | @snippets = case params[:scope] | 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 | else | 33 | else |
34 | @snippets | 34 | @snippets |
35 | end | 35 | end |
36 | else | 36 | else |
37 | - @snippets = @snippets.is_public | 37 | + @snippets = @snippets.are_public |
38 | end | 38 | end |
39 | 39 | ||
40 | @snippets = @snippets.page(params[:page]).per(20) | 40 | @snippets = @snippets.page(params[:page]).per(20) |
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 :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 | 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]) } |
app/views/snippets/current_user_index.html.haml
@@ -18,16 +18,16 @@ | @@ -18,16 +18,16 @@ | ||
18 | All | 18 | All |
19 | %span.pull-right | 19 | %span.pull-right |
20 | = @user.snippets.count | 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 | Private | 23 | Private |
24 | %span.pull-right | 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 | Public | 28 | Public |
29 | %span.pull-right | 29 | %span.pull-right |
30 | - = @user.snippets.is_public.count | 30 | + = @user.snippets.are_public.count |
31 | 31 | ||
32 | .col-md-9.my-snippets | 32 | .col-md-9.my-snippets |
33 | = render 'snippets' | 33 | = render 'snippets' |
config/initializers/state_machine_patch.rb
@@ -2,8 +2,8 @@ | @@ -2,8 +2,8 @@ | ||
2 | # where gem 'state_machine' was not working for Rails 4.1 | 2 | # where gem 'state_machine' was not working for Rails 4.1 |
3 | module StateMachine | 3 | module StateMachine |
4 | module Integrations | 4 | module Integrations |
5 | - module ActiveModel | ||
6 | - public :around_validation | ||
7 | - end | 5 | + module ActiveModel |
6 | + public :around_validation | ||
7 | + end | ||
8 | end | 8 | end |
9 | end | 9 | end |