From 2b0f75e62ba19502492ec9237dbf3caedc668485 Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 8 Jun 2018 16:59:09 -0400 Subject: [PATCH] join page tweaks --- app/controllers/rooms_controller.rb | 15 +++------------ app/views/rooms/join.html.erb | 14 +++++--------- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index 6a22bfd0..8aed5af7 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -74,12 +74,8 @@ class RoomsController < ApplicationController # GET /r/:room_uid/logout def logout - # Redirect the owner to their room. - if current_user - redirect_to current_user.main_room - else - redirect_to root_path - end + # Redirect the correct page. + redirect_to @room end # POST /r/:room_uid/home @@ -127,12 +123,7 @@ class RoomsController < ApplicationController # Find the room from the uid. def find_room - @room = Room.find_by(uid: params[:room_uid]) - - if @room.nil? - # Handle room doesn't exist. - - end + @room = Room.find_by!(uid: params[:room_uid]) end # Ensure the user is logged into the room they are accessing. diff --git a/app/views/rooms/join.html.erb b/app/views/rooms/join.html.erb index dd051be3..afdde7bb 100644 --- a/app/views/rooms/join.html.erb +++ b/app/views/rooms/join.html.erb @@ -1,14 +1,10 @@ <%= render 'shared/room_event' do %> <%= form_for room_path, method: :post do |f| %> -
- <% if current_user %> - <%= f.submit "Join", class: "btn btn-primary px-7 main-large join-button"%> - <% else %> - <%= f.text_field :join_name, class: "form-control main-large", placeholder: "Enter your name!" %> - - <%= f.submit "Join", class: "btn btn-primary px-7 main-large" %> - - <% end %> +
+ <%= f.text_field :join_name, class: "form-control main-large", placeholder: "Enter your name!", value: "#{current_user ? current_user.name : ''}" %> + + <%= f.submit "Join", class: "btn btn-primary px-7 main-large" %> +
<% end %> <% end %>