Class: RoomsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
lib/generators/sbmeet/templates/controllers/rooms_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
# File 'lib/generators/sbmeet/templates/controllers/rooms_controller.rb', line 13

def create
  @room = Room.new(room_params)
  if @room.save
    redirect_to @room
  else
    render :index, status: :unprocessable_entity
  end
end

#destroyObject



22
23
24
25
26
27
28
29
30
# File 'lib/generators/sbmeet/templates/controllers/rooms_controller.rb', line 22

def destroy
  if current_user
    @room = Room.find(params[:id])
    @room.destroy
    redirect_to rooms_path, notice: "Room deleted successfully."
  else
    redirect_to rooms_path, alert: "You do not have permission to delete this room."
  end
end

#indexObject



3
4
5
6
# File 'lib/generators/sbmeet/templates/controllers/rooms_controller.rb', line 3

def index
  @rooms = Room.all
  @room = Room.new
end

#showObject



8
9
10
11
# File 'lib/generators/sbmeet/templates/controllers/rooms_controller.rb', line 8

def show
  @room = Room.find(params[:id])
  @active_users = [@current_user] 
end