Skip to content
Browse files

homepage for invitees

  • Loading branch information...
1 parent 9fb65b1 commit ec71838245ca8f3ee00fbe7e8564a85cd4b04454 Cyril Fluck committed Jan 28, 2012
View
8 app/controllers/canvas_controller.rb
@@ -1,8 +1,14 @@
class CanvasController < ApplicationController
def index
+ @new_invitee = false
+
if @signed_request && @signed_request["user_id"]
user = User.where(:facebook_id => @signed_request["user_id"]).first
- sign_in( user ) if user
+ if user
+ sign_in( user )
+ elsif Invitation.where( :invitee_id => @signed_request['user_id'] ).count > 0
+ @new_invitee = true
+ end
end
end
View
3 app/controllers/invitations_controller.rb
@@ -5,7 +5,6 @@ class InvitationsController < ApplicationController
# GET /invitations
# GET /invitations.json
def index
- debugger
@invitations = Invitation.all
respond_to do |format|
@@ -89,5 +88,7 @@ def callback
params[:to].each_value do | facebook_id |
Invitation.create( user: current_user, invitee_id: facebook_id )
end
+
+ redirect_to invitations_path, :notice => "#{params[:to].length} friend(s) invited."
end
end
View
8 app/views/canvas/index.html.haml
@@ -1,9 +1,7 @@
- if current_user
+- elsif @new_invitee
+ %h1 Welcome to TennisYourWorld
+ = link_to 'Join Us!', user_omniauth_callback_path
- else
- <script src="http://connect.facebook.net/en_US/all.js"></script>
- <div id="fb-root"></div>
- %script
- FB.init({appId: '185797408106593', xfbml: true, cookie: true, oauth: true});
- FB.login({scope: 'email});
%h1 We're sorry, but TennisYourWorld is a private group.
%p You need to be invited by a member in order to access this content.
View
2 app/views/invitations/index.html.erb
@@ -12,7 +12,7 @@
<% @invitations.each do |invitation| %>
<tr>
<td><%= invitation.user %></td>
- <td><%= invitation.invitee %></td>
+ <td><%= invitation.invitee_id %></td>
<td><%= link_to 'Show', invitation %></td>
<td><%= link_to 'Edit', edit_invitation_path(invitation) %></td>
<td><%= link_to 'Destroy', invitation, confirm: 'Are you sure?', method: :delete %></td>

0 comments on commit ec71838

Please sign in to comment.
Something went wrong with that request. Please try again.