Skip to content

Instantly share code, notes, and snippets.

@SeanRoberts
Created October 5, 2015 16:46
Show Gist options
  • Save SeanRoberts/430058474c34d2779d34 to your computer and use it in GitHub Desktop.
Save SeanRoberts/430058474c34d2779d34 to your computer and use it in GitHub Desktop.
class Tenon::ProfileSpecificResourcesController < Tenon::ResourcesController
before_filter :authorize_site
def index
params[:page] = 1 if params[:page].to_i == 0
respond_to do |format|
format.html
format.json do
self.collection = current_profile.send(plural_name)
self.collection = collection.where(search_args) if params[:q]
self.collection = collection.paginate(per_page: 20, page: params[:page])
self.collection = Tenon::PaginatingDecorator.decorate(collection)
end
end
end
def update
resource_params[:profile_id] = current_profile.id
super
end
def create
resource_params[:profile_id] = current_profile.id
super
end
private
def self.load_options
super.merge(through: current_profile)
end
def authorize_site
authorize!(:edit, current_profile)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment