diff --git a/app/controllers/community_controller.rb b/app/controllers/community_controller.rb index faa88bf..826fb12 100644 --- a/app/controllers/community_controller.rb +++ b/app/controllers/community_controller.rb @@ -16,14 +16,16 @@ def index def hottest hottest_articles = Article.hottest hottest_articles = order hottest_articles - @articles = hottest_articles.paginate page: params[:page], per_page: 15 + @articles = hottest_articles.paginate page: params[:page], per_page: 15 unless hottest_articles.blank? + @articles ||= [] articles_during_time hottest_articles end def latest latest_articles = Article.latest latest_articles = order latest_articles - @articles = latest_articles.paginate page: params[:page], per_page: 15 + @articles = latest_articles.paginate page: params[:page], per_page: 15 unless latest_articles.blank? + @articles ||= [] articles_during_time latest_articles end @@ -32,7 +34,8 @@ def tag return render_404 unless @tag posted_articles = @tag.articles.where posted: true @article_size = posted_articles.size - @articles = posted_articles.paginate page: params[:page], per_page: 15 + @articles = posted_articles.paginate page: params[:page], per_page: 15 unless posted_articles.blank? + @articles ||= [] end def articles @@ -61,7 +64,8 @@ def articles Article.where posted: true end @article_size = articles.size - @articles = articles.paginate page: params[:page], per_page: 15 + @articles = articles.paginate page: params[:page], per_page: 15 unless articles.blank? + @articles ||= [] end def users @@ -76,7 +80,7 @@ def get_user end def order(articles) - return nil if articles.blank? + return [] if articles.blank? case params[:order] when 'time' @opt = 0 diff --git a/app/views/community/_articles_list.html.erb b/app/views/community/_articles_list.html.erb index eb1895d..e6c646b 100644 --- a/app/views/community/_articles_list.html.erb +++ b/app/views/community/_articles_list.html.erb @@ -11,7 +11,7 @@ <% end %> - <%= will_paginate articles, renderer: WillPaginate::ActionView::BlogLinkRenderer %> + <%= will_paginate articles, renderer: WillPaginate::ActionView::BlogLinkRenderer unless articles.blank? %> diff --git a/app/views/community/hottest.html.erb b/app/views/community/hottest.html.erb index 43a312d..a1a89b8 100644 --- a/app/views/community/hottest.html.erb +++ b/app/views/community/hottest.html.erb @@ -18,7 +18,7 @@ <% end %> - <%= will_paginate @articles, renderer: WillPaginate::ActionView::BlogLinkRenderer %> + <%= will_paginate @articles, renderer: WillPaginate::ActionView::BlogLinkRenderer unless @articles.blank? %> - <%= will_paginate @articles, renderer: WillPaginate::ActionView::BlogLinkRenderer %> + <%= will_paginate @articles, renderer: WillPaginate::ActionView::BlogLinkRenderer unless @articles.blank? %>