room resources

This commit is contained in:
Josh 2018-05-29 16:51:18 -04:00
parent 32ec2bacce
commit de44d8024b
5 changed files with 25 additions and 14 deletions

View File

@ -11,8 +11,13 @@ class RoomsController < ApplicationController
room.user = current_user
if room.save
redirect_to room
if room_params[:auto_join] == "1"
redirect_to start_room_path(room)
else
redirect_to room
end
else
# Handle room didn't save.
end
end
@ -45,6 +50,13 @@ class RoomsController < ApplicationController
end
end
# DELETE /r/:room_uid
def destroy
@room.destroy
redirect_to root_path
end
# GET /r/:room_uid/start
def start
# Join the user in and start the meeting.

View File

@ -38,7 +38,6 @@
<% if current_user %>
<%= render "shared/modals/create_room_modal" %>
<% end %>
</div>
</body>
</html>

View File

@ -8,7 +8,7 @@
<td>
<div><%= room.name %></div>
<div class="small text-muted">
<i>Created on <%= room.created_at.strftime("%B #{room.created_at.day.ordinalize}, %Y") %></i>
<i>Created on <%= room.created_at.strftime("%B #{room.created_at.day.ordinalize}, %Y.") %></i>
</div>
</td>
<td class="text-right">
@ -17,7 +17,9 @@
<div class="dropdown-menu dropdown-menu-right">
<a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fe fe-tag"></i> Action </a>
<a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fe fe-edit-2"></i> Another action </a>
<a href="javascript:void(0)" class="dropdown-item"><i class="dropdown-icon fe fe-trash"></i> Delete</a>
<%= button_to room, method: :delete, data: { confirm: 'Are you sure?' }, class: "dropdown-item" do %>
<i class="dropdown-icon fe fe-trash"></i> Delete
<% end %>
</div>
</div>
</td>

View File

@ -8,7 +8,7 @@
</div>
<hr class="small-rule">
<%= form_for(:room, url: create_room_path) do |f| %>
<%= form_for(:room, url: rooms_path) do |f| %>
<div class="input-icon">
<span class="input-icon-addon">
<i class="fas fa-chalkboard-teacher"></i>

View File

@ -1,15 +1,13 @@
Rails.application.routes.draw do
resources :rooms, only: [:create, :show, :destroy], param: :room_uid, path: '/r'
# Room routes.
scope '/r' do
post '/', to: 'rooms#create', as: :create_room
scope '/:room_uid' do
match '/', to: 'rooms#show', as: :room, via: [:get, :post]
get '/start', to: 'rooms#start', as: :start_room
match '/wait', to: 'rooms#wait', as: :wait_room, via: [:get, :post]
get '/logout', to: 'rooms#logout', as: :logout_room
get '/sessions', to: 'rooms#sessions', as: :sessions
end
scope '/r/:room_uid' do
get '/start', to: 'rooms#start', as: :start_room
match '/wait', to: 'rooms#wait', as: :wait_room, via: [:get, :post]
get '/logout', to: 'rooms#logout', as: :logout_room
get '/sessions', to: 'rooms#sessions', as: :sessions
end
# Signup routes.