app/controllers/simple_pages/pages_controller.rb in simple-pages-rails-0.0.1 vs app/controllers/simple_pages/pages_controller.rb in simple-pages-rails-0.1.0
- old
+ new
@@ -1,18 +1,19 @@
require_dependency 'simple_pages/application_controller'
module SimplePages
class PagesController < ApplicationController
before_filter :authenticate_session!, except: [:show]
+
load_resource class: 'SimplePages::Page', only: [:index]
before_filter :new_page, only: [:new, :create]
load_resource class: 'SimplePages::Page', find_by: :url, only: [:show, :edit, :update, :destroy]
authorize_resource class: 'SimplePages::Page', except: [:show]
def index
- @pages = @pages.paginate page: params[:page]
+ @pages = @pages.paginate pagination_options
respond_with @pages
end
def show
respond_with @page
@@ -65,8 +66,12 @@
def load_author_options
load_authors
@author_options = @authors.map do |author|
[author.name, author.simple_page_owner_option]
end
+ end
+
+ def pagination_options
+ { page: params[:page], per_page: SimplePages.pages_per_page }
end
end
end