Class: Channels::MembersController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/dune/api/v1/channels/members_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/dune/api/v1/channels/members_controller.rb', line 10

def create
  channel_member = parent.channel_members.build(
    user_id: params[:channel_member].try(:[], :user_id)
  )
  if channel_member.save
    render json: channel_member.user, status: :created
  else
    respond_with channel_member
  end
end

#destroyObject



21
22
23
24
# File 'app/controllers/dune/api/v1/channels/members_controller.rb', line 21

def destroy
  parent.channel_members.find_by(user_id: params[:id]).delete
  head :no_content
end

#indexObject



6
7
8
# File 'app/controllers/dune/api/v1/channels/members_controller.rb', line 6

def index
  respond_with parent.members, root: 'users'
end