Skip to content

Instantly share code, notes, and snippets.

@adamniedzielski
Created December 20, 2014 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamniedzielski/f376b0bfcf7011862433 to your computer and use it in GitHub Desktop.
Save adamniedzielski/f376b0bfcf7011862433 to your computer and use it in GitHub Desktop.
class Admin::ItemsController < ApplicationController
def index
item_resource = ItemResource.new(params)
@items = item_resource.fetch_for_index
@form = item_resource.form
end
end
class Admin::ItemResource
include AdminBits
def filters
[:having_name, :price_between]
end
def having_name(filter_params)
resource_class.having_name(filter_params[:name])
end
def price_between(filter_params)
# ...
end
def ordering
[:name, :price]
end
def default_order
:price
end
def default_direction
:desc
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment