diff --git a/app/controllers/table_invites_controller.rb b/app/controllers/table_invites_controller.rb index 19e45c2..49affb9 100644 --- a/app/controllers/table_invites_controller.rb +++ b/app/controllers/table_invites_controller.rb @@ -5,7 +5,7 @@ class TableInvitesController < ApplicationController before_action :set_table_invite, only: [ :edit, :update ] def index - @table_invites = TableInvite.where(email: Current.user.email) + @table_invites = TableInvite.where(email: Current.user.email).not_responded end def new diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 61f678f..df1837a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2,6 +2,7 @@ class UsersController < ApplicationController skip_before_action :authenticate, only: [ :new, :create ] + before_action :set_user, only: [ :show ] def new @user = User.new @@ -20,6 +21,12 @@ class UsersController < ApplicationController end end + def show + if @user == Current.user + @table_invites = TableInvite.where(email: @user.email).not_responded + end + end + private def user_params @@ -32,4 +39,8 @@ class UsersController < ApplicationController :last_name, ) end + + def set_user + @user = User.find_by(username: params[:id]) + end end diff --git a/app/models/user.rb b/app/models/user.rb index 0247ab8..8c59498 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -37,6 +37,10 @@ class User < ApplicationRecord scope :verified, -> { where(verified: true) } scope :unverified, -> { where(verified: false) } + def to_param + username + end + def full_name return first_name if last_name.blank? diff --git a/app/views/table_invites/index.html.erb b/app/views/table_invites/index.html.erb index a9c1b2d..1956ec1 100644 --- a/app/views/table_invites/index.html.erb +++ b/app/views/table_invites/index.html.erb @@ -4,7 +4,7 @@ <% if @table_invites.any? %> <% @table_invites.each do |table_invite| %> - <%= link_to table_invite.table, edit_table_invite_path(table_invite) %> + <%= link_to table_invite.table.name, edit_table_invite_path(table_invite) %> <% end %> <% else %>
<%= t(".no_table_invites") %>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb new file mode 100644 index 0000000..313266b --- /dev/null +++ b/app/views/users/show.html.erb @@ -0,0 +1,7 @@ +<%= content_for :title, @user.username %> + +