Skip to content

Commit

Permalink
fix bugs with globalize, published_before and clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
keram committed Aug 29, 2012
1 parent 50661cc commit a5ece32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/controllers/refinery/blog/posts_controller.rb
Expand Up @@ -10,7 +10,7 @@ class PostsController < BlogController

def index
# Rss feeders are greedy. Let's give them every blog post instead of paginating.
(@posts = Post.live.includes(:comments, :categories).with_globalize) if request.format.rss?
(@posts = Post.live.includes(:comments, :categories)) if request.format.rss?
respond_with (@posts) do |format|
format.html
format.rss { render :layout => false }
Expand Down Expand Up @@ -71,7 +71,7 @@ def archive
def tagged
@tag = ActsAsTaggableOn::Tag.find(params[:tag_id])
@tag_name = @tag.name
@posts = Post.tagged_with(@tag_name).with_globalize.page(params[:page])
@posts = Post.live.tagged_with(@tag_name).page(params[:page])
end

protected
Expand Down
10 changes: 5 additions & 5 deletions app/models/refinery/blog/post.rb
Expand Up @@ -86,7 +86,7 @@ def find_by_slug_or_id(slug_or_id)
end

def by_month(date)
where(:published_at => date.beginning_of_month..date.end_of_month).with_globalize
where(:published_at => date.beginning_of_month..date.end_of_month)
end

def by_archive(date)
Expand All @@ -99,23 +99,23 @@ def by_year(date)
end

def published_dates_older_than(date)
published_before(date).with_globalize.pluck(:published_at)
published_before(date).pluck(:published_at)
end

def recent(count)
live.limit(count).with_globalize
live.limit(count)
end

def popular(count)
unscoped.order("access_count DESC").limit(count).with_globalize
end

def previous(item)
published_before(item.published_at).with_globalize.first
published_before(item.published_at).first
end

def uncategorized
live.includes(:categories).where(Refinery::Categorization.table_name => { :blog_category_id => nil }).with_globalize
live.includes(:categories).where(Refinery::Categorization.table_name => { :blog_category_id => nil })
end

def next(current_record)
Expand Down

0 comments on commit a5ece32

Please sign in to comment.