Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/admin/articles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def autosave
@article.text_filter_name ||= default_text_filter

if @article.title.blank?
lastid = Article.order("id desc").first.id
lastid = Article.order(id: :desc).first.id
@article.title = "Draft article #{lastid}"
end

Expand Down
4 changes: 2 additions & 2 deletions app/controllers/admin/redirects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ class Admin::RedirectsController < Admin::BaseController
before_action :set_redirect, only: [:edit, :update, :destroy]

def index
@redirects = Redirect.where(content_id: nil).order("id desc").page(params[:page])
@redirects = Redirect.where(content_id: nil).order(id: :desc).page(params[:page])
.per(this_blog.admin_display_elements)
@redirect = Redirect.new
end

def edit
@redirects = Redirect.where(content_id: nil).order("id desc").page(params[:page])
@redirects = Redirect.where(content_id: nil).order(id: :desc).page(params[:page])
.per(this_blog.admin_display_elements)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/resources_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def upload

def index
@r = Resource.new
@resources = Resource.order("created_at DESC").page(params[:page])
@resources = Resource.order(created_at: :desc).page(params[:page])
.per(this_blog.admin_display_elements)
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin/tags_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def tag_params
end

def fetch_tags
@tags = Tag.order("display_name").page(params[:page])
@tags = Tag.order(:display_name).page(params[:page])
.per(this_blog.admin_display_elements)
end
end
2 changes: 1 addition & 1 deletion app/controllers/admin/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Admin::UsersController < Admin::BaseController
before_action :set_user, only: [:edit, :update, :destroy]

def index
@users = User.order("login asc").page(params[:page])
@users = User.order(:login).page(params[:page])
.per(this_blog.admin_display_elements)
end

Expand Down
8 changes: 4 additions & 4 deletions app/models/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Article < Content
"contents.state" => "published")
.group("contents.id")
.select("contents.*, count(feedback.id) as comment_count")
.order("comment_count DESC")
.order(comment_count: :desc)
.limit(5)
}

Expand Down Expand Up @@ -106,7 +106,7 @@ def self.search_with(params)
scoped = scoped.send(params[:state])
end

scoped.order("created_at DESC")
scoped.order(created_at: :desc)
end

# FIXME: Use keyword params to clean up call sites.
Expand Down Expand Up @@ -140,12 +140,12 @@ def feed_url(format)
end

def next
Article.where("published_at > ?", published_at).order("published_at asc")
Article.where("published_at > ?", published_at).order(:published_at)
.limit(1).first
end

def previous
Article.where(published_at: ...published_at).order("published_at desc")
Article.where(published_at: ...published_at).order(published_at: :desc)
.limit(1).first
end

Expand Down
4 changes: 2 additions & 2 deletions app/models/blog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class Blog < ApplicationRecord
has_many :notes

has_many :redirects
has_many :sidebars, ->() { order("active_position ASC") }
has_many :sidebars, ->() { order(:active_position) }

attr_accessor :custom_permalink

default_scope -> { order("id") }
default_scope -> { order(:id) }

validates :blog_name, presence: true

Expand Down
2 changes: 1 addition & 1 deletion app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Comment < Feedback
scope :ham, -> { where(state: "ham") }
scope :unconfirmed, -> { where(state: %w(presumed_spam presumed_ham)) }

scope :last_published, -> { published.limit(5).order("created_at DESC") }
scope :last_published, -> { published.limit(5).order(created_at: :desc) }

def notify_user_via_email(user)
EmailNotify.send_comment(self, user) if user.notify_via_email?
Expand Down
6 changes: 3 additions & 3 deletions app/models/content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class Content < ApplicationRecord
published.where(published_at: PublifyTime.delta(*time_params))
}
scope :not_published, -> { where.not(state: "published") }
scope :drafts, -> { where(state: "draft").order("created_at DESC") }
scope :no_draft, -> { where.not(state: "draft").order("published_at DESC") }
scope :drafts, -> { where(state: "draft").order(created_at: :desc) }
scope :no_draft, -> { where.not(state: "draft").order(published_at: :desc) }
scope :searchstring, lambda { |search_string|
result = where(state: "published")

Expand Down Expand Up @@ -119,6 +119,6 @@ def rss_description
end

def short_url
redirect.from_url if redirect.present?
redirect&.from_url
end
end
2 changes: 1 addition & 1 deletion app/models/feedback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def akismet_client
end

def blog_id
article.blog_id if article.present?
article.blog_id
end

def plural_model_name
Expand Down
2 changes: 1 addition & 1 deletion app/models/note.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Note < Content
scope :published, lambda {
where(state: "published").where(published_at: ..Time.zone.now).order(default_order)
}
default_scope { order("published_at DESC") }
default_scope { order(published_at: :desc) }

TWITTER_FTP_URL_LENGTH = 19
TWITTER_HTTP_URL_LENGTH = 20
Expand Down
4 changes: 2 additions & 2 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ def self.find_all_with_content_counters
.where(contents: { state: "published" })
.select(*Tag.column_names, "COUNT(contents_tags.content_id) as content_counter")
.group(*Tag.column_names)
.order("content_counter DESC").limit(1000)
.order(content_counter: :desc).limit(1000)
end

def self.find_with_char(char)
where("name LIKE ? ", "%#{char}%").order("name ASC")
where("name LIKE ? ", "%#{char}%").order(:name)
end

def self.collection_to_string(tags)
Expand Down
2 changes: 1 addition & 1 deletion publify_core.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "rubocop-capybara", "~> 2.22.1"
s.add_development_dependency "rubocop-factory_bot", "~> 2.27.1"
s.add_development_dependency "rubocop-performance", "~> 1.26.1"
s.add_development_dependency "rubocop-rails", "~> 2.32.0"
s.add_development_dependency "rubocop-rails", "~> 2.34.3"
s.add_development_dependency "rubocop-rspec", "~> 3.7.0"
s.add_development_dependency "rubocop-rspec_rails", "~> 2.32.0"
s.add_development_dependency "shoulda-matchers", "~> 6.0"
Expand Down