Skip to content

Instantly share code, notes, and snippets.

@darelvc
Created March 11, 2016 08:02
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 darelvc/7d19e83497d43264807b to your computer and use it in GitHub Desktop.
Save darelvc/7d19e83497d43264807b to your computer and use it in GitHub Desktop.
Chats_controller.rb
class Api::ChatsController < Api::BaseController
load_and_authorize_resource
private
def build_resource
@chat = Chat.build current_user, resource_params
end
def collection
#@chats ||= Chat.all.decorate
@chats ||= current_user.chats
end
def resource
@chat ||= Chat.find params[:id]
end
def resource_params
params.require(:chat).permit(:id, :name, :description, user_ids: [])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment