diff --git a/app/controllers/join_codes_controller.rb b/app/controllers/join_codes_controller.rb index 6d790c232..863522893 100644 --- a/app/controllers/join_codes_controller.rb +++ b/app/controllers/join_codes_controller.rb @@ -29,10 +29,14 @@ class JoinCodesController < ApplicationController private def set_join_code - @join_code ||= Account::JoinCode.active.find_by(code: params.expect(:code), account: Current.account) + @join_code ||= Account::JoinCode.find_by(code: params.expect(:code), account: Current.account) end def ensure_join_code_is_valid - head :not_found unless @join_code&.active? + if @join_code.nil? + head :not_found + elsif !@join_code.active? + render :inactive, status: :gone + end end end diff --git a/app/views/join_codes/inactive.html.erb b/app/views/join_codes/inactive.html.erb new file mode 100644 index 000000000..1bddb6e42 --- /dev/null +++ b/app/views/join_codes/inactive.html.erb @@ -0,0 +1,15 @@ +<% @page_title = "You can't join #{@join_code.account.name} right now." %> + +
This join code has no invitations left on it.
+ ++ <%= link_to "Check out Fizzy", "https://www.fizzy.do" %>. +
+