From 90c2e0d971b5c105224196b8509012f943c9ea9b Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Fri, 30 May 2014 17:21:14 +0200 Subject: Replace now forbidden keywords public and private for snippets scope --- app/controllers/snippets_controller.rb | 2 +- app/models/snippet.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 0dd941a48e2..59ad8ff907c 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -14,7 +14,7 @@ class SnippetsController < ApplicationController layout 'navless' 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 def user_index diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 720accd73dc..0727bb16398 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -34,8 +34,8 @@ class Snippet < ActiveRecord::Base validates :content, presence: true # Scopes - scope :public, -> { where(private: false) } - scope :private, -> { where(private: true) } + scope :is_public, -> { where(private: false) } + scope :is_private, -> { where(private: true) } scope :fresh, -> { order("created_at DESC") } 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]) } -- cgit v1.2.3 From 79f8abc51fa876e12de4150ab3ec489208aaed84 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Mon, 2 Jun 2014 10:20:37 +0200 Subject: Replace snippets scopes in view and controller. --- app/controllers/snippets_controller.rb | 10 +++++----- app/views/snippets/current_user_index.html.haml | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'app') diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 59ad8ff907c..89edd9fd7e1 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -26,15 +26,15 @@ class SnippetsController < ApplicationController if @user == current_user @snippets = case params[:scope] - when 'public' then - @snippets.public - when 'private' then - @snippets.private + when 'is_public' then + @snippets.is_public + when 'is_private' then + @snippets.is_private else @snippets end else - @snippets = @snippets.public + @snippets = @snippets.is_public end @snippets = @snippets.page(params[:page]).per(20) diff --git a/app/views/snippets/current_user_index.html.haml b/app/views/snippets/current_user_index.html.haml index 90ddc7198f6..3e030428701 100644 --- a/app/views/snippets/current_user_index.html.haml +++ b/app/views/snippets/current_user_index.html.haml @@ -18,16 +18,16 @@ All %span.pull-right = @user.snippets.count - = nav_tab :scope, 'private' do - = link_to user_snippets_path(@user, scope: 'private') do + = nav_tab :scope, 'is_private' do + = link_to user_snippets_path(@user, scope: 'is_private') do Private %span.pull-right - = @user.snippets.private.count - = nav_tab :scope, 'public' do - = link_to user_snippets_path(@user, scope: 'public') do + = @user.snippets.is_private.count + = nav_tab :scope, 'is_public' do + = link_to user_snippets_path(@user, scope: 'is_public') do Public %span.pull-right - = @user.snippets.public.count + = @user.snippets.is_public.count .col-md-9.my-snippets = render 'snippets' -- cgit v1.2.3 From 7bf64b2648f4d23ad6850641d52b06b1fc447b81 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Mon, 2 Jun 2014 11:28:32 +0200 Subject: Convert to array since Relation no longer returns an array. --- app/controllers/projects_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 6ea9b2cf27d..7401b28ea1d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -217,6 +217,6 @@ class ProjectsController < ApplicationController end def sorted(users) - users.uniq.compact.sort_by(&:username).map { |user| { username: user.username, name: user.name } } + users.uniq.to_a.compact.sort_by(&:username).map { |user| { username: user.username, name: user.name } } end end -- cgit v1.2.3 From 18b1f171bd0b9700e73c37c23150bea9fb251b3e Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 4 Jun 2014 08:37:19 +0200 Subject: Rename snippets scopes to plural names. --- app/controllers/snippets_controller.rb | 12 ++++++------ app/models/snippet.rb | 4 ++-- app/views/snippets/current_user_index.html.haml | 12 ++++++------ 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'app') diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 89edd9fd7e1..4fe98f804dc 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -14,7 +14,7 @@ class SnippetsController < ApplicationController layout 'navless' 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 def user_index @@ -26,15 +26,15 @@ class SnippetsController < ApplicationController if @user == current_user @snippets = case params[:scope] - when 'is_public' then - @snippets.is_public - when 'is_private' then - @snippets.is_private + when 'are_public' then + @snippets.are_public + when 'are_private' then + @snippets.are_private else @snippets end else - @snippets = @snippets.is_public + @snippets = @snippets.are_public end @snippets = @snippets.page(params[:page]).per(20) diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 0727bb16398..9e4409daa1a 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -34,8 +34,8 @@ class Snippet < ActiveRecord::Base validates :content, presence: true # Scopes - scope :is_public, -> { where(private: false) } - scope :is_private, -> { where(private: true) } + scope :are_public, -> { where(private: false) } + scope :are_private, -> { where(private: true) } scope :fresh, -> { order("created_at DESC") } 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]) } diff --git a/app/views/snippets/current_user_index.html.haml b/app/views/snippets/current_user_index.html.haml index 3e030428701..e3edd856983 100644 --- a/app/views/snippets/current_user_index.html.haml +++ b/app/views/snippets/current_user_index.html.haml @@ -18,16 +18,16 @@ All %span.pull-right = @user.snippets.count - = nav_tab :scope, 'is_private' do - = link_to user_snippets_path(@user, scope: 'is_private') do + = nav_tab :scope, 'are_private' do + = link_to user_snippets_path(@user, scope: 'are_private') do Private %span.pull-right - = @user.snippets.is_private.count - = nav_tab :scope, 'is_public' do - = link_to user_snippets_path(@user, scope: 'is_public') do + = @user.snippets.are_private.count + = nav_tab :scope, 'are_public' do + = link_to user_snippets_path(@user, scope: 'are_public') do Public %span.pull-right - = @user.snippets.is_public.count + = @user.snippets.are_public.count .col-md-9.my-snippets = render 'snippets' -- cgit v1.2.3