Skip to content
This repository has been archived by the owner on Jan 25, 2022. It is now read-only.

Commit

Permalink
テストが通るように修正
Browse files Browse the repository at this point in the history
  • Loading branch information
YOSHIDA Hiroki committed Jan 13, 2014
1 parent 0de27d1 commit 4e8a752
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class HomeController < ApplicationController
def index
@clips = Clip.paginate(page: params[:page]).includes([ { image: :likes, comments: :user }, :user, :likes, :tags ])
@hot_tags = Tag.new(50).shuffle
@hot_tags = Tag.newest(50).shuffle
@new_matomes = Matome.limit(5).all
render action: 'next_page' unless first_page?
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class Tag < ActiveRecord::Base
scope :uniques, group(:name)
scope :by, lambda {|user| where(user_id: user.is_a?(User) ? user.id : user) if user }
scope :for, lambda {|tagged| where(tagged_id: tagged.id, tagged_type: tagged.class.name) }
scope :new, lambda {|limit| uniques.select("name, COUNT(name) AS name_count, MAX(updated_at) AS newest_updated_at").reorder('newest_updated_at desc').limit(limit) }
scope :hot, lambda {|limit| uniques.select("name, COUNT(name) AS name_count").reorder('name_count desc').limit(limit) }
scope :newest, lambda {|limit| uniques.select("name, COUNT(name) AS name_count, MAX(updated_at) AS newest_updated_at").reorder('newest_updated_at desc').limit(limit) }
scope :hottest, lambda {|limit| uniques.select("name, COUNT(name) AS name_count").reorder('name_count desc').limit(limit) }

validates :tagged_id, :presence => true
validates :user_id, :presence => true
Expand Down

0 comments on commit 4e8a752

Please sign in to comment.