Class: Admin::BooksController

Inherits:
Releaf::ActionController
  • Object
show all
Defined in:
lib/generators/dummy/templates/controllers/admin/books_controller.rb

Instance Method Summary collapse

Instance Method Details

#resourcesObject


7
8
9
10
11
12
13
14
15
# File 'lib/generators/dummy/templates/controllers/admin/books_controller.rb', line 7

def resources
  relation = super

  relation = relation.where(active: true) if params[:only_active]
  relation = relation.where( 'published_at >= ?', params[:published_since]) if params[:published_since].present?
  relation = relation.where( 'published_at <= ?', params[:published_up_to]) if params[:published_up_to].present?

  relation
end

#searchable_fieldsObject


3
4
5
# File 'lib/generators/dummy/templates/controllers/admin/books_controller.rb', line 3

def searchable_fields
  [:title, :genre, author: [:name] ]
end