Skip to content

Commit

Permalink
Fixed will_paginate behavior changed by gem version update (it's no more
Browse files Browse the repository at this point in the history
Array).
  • Loading branch information
yoosee committed Sep 14, 2018
1 parent 5e4d436 commit aae40b1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ gem 'coffee-rails', '~> 4.2.2'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

gem 'bootsnap', '>= 1.1.0', require: false

gem 'unicorn'

gem 'bootstrap-sass' #, '3.2.0.0'
Expand Down Expand Up @@ -58,8 +60,9 @@ end

group :development do
# gem 'rspec-rails'
gem 'web-console', '~> 2.0'
gem 'web-console'
gem 'spring'
gem 'listen'

gem 'better_errors'
# gem 'quiet_assets'
Expand Down
16 changes: 9 additions & 7 deletions app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ def home

def index
# index shows all articles belongs to specific blog_id and status: published regardless users
articles = Article.where(blog_id: @blog.id).unscoped.published.order("published_at DESC").paginate(page: params[:page], :per_page => 5)
@articles = articles.each do |article|
# articles = Article.where(blog_id: @blog.id).unscoped.published.order("published_at DESC").paginate(page: params[:page], :per_page => 5)
# @articles_page particularly for will_paginate, while @article is Array for general use with markdown to html transferred
@articles_page = Article.where(blog_id: @blog.id).page(params[:page]).per_page(5).published.order("published_at DESC")
@articles = @articles_page.each do |article|
article.content = markdown article.content
end
end
Expand All @@ -30,11 +32,11 @@ def rss
end

def drafts
# Drafts shows draft articles belongs to current_user
articles = current_user.articles.unscoped.draft.order("updated_at DESC").paginate(page: params[:page], :per_page => 10)
@articles = articles.each do |article|
article.content = markdown article.content
end
# Drafts shows draft articles belongs to current_user. it isn't converted to html
@articles = current_user.articles.unscoped.draft.order("updated_at DESC").paginate(page: params[:page], :per_page => 10)
# @articles = articles.each do |article|
# article.content = markdown article.content
# end
end

def create
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions app/views/articles/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<small>a blog on first go without spending ages practicing.</small></h1>
</div>

<%= will_paginate %>
<%= will_paginate @articles_page %>

<div class="articles">
<% @articles.each do |article| %>
Expand All @@ -14,4 +14,4 @@
<% end %>
</div>

<%= will_paginate %>
<%= will_paginate @articles_page %>
1 change: 1 addition & 0 deletions config/initializers/will_paginate_array.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#require 'will_paginate/array'

0 comments on commit aae40b1

Please sign in to comment.