Skip to content

Commit de1dc1d

Browse files
committed
after a new user signs up, nag them to invite someone
1 parent 87cb2cb commit de1dc1d

7 files changed

+67
-29
lines changed

app/controllers/invitations_controller.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ def create
2020
"address is valid."
2121
end
2222

23-
return redirect_to "/settings"
23+
if params[:return_home]
24+
return redirect_to "/"
25+
else
26+
return redirect_to "/settings"
27+
end
2428
end
2529
end

app/controllers/signup_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def signup
4545

4646
Countinual.count!("lobsters.users.created", "+1")
4747

48-
return redirect_to "/"
48+
return redirect_to "/users/invite"
4949
else
5050
render :action => "invited"
5151
end

app/controllers/users_controller.rb

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
class UsersController < ApplicationController
2+
before_filter :require_logged_in_user, :only => :invite
3+
24
def show
35
@showing_user = User.find_by_username!(params[:id])
46
@title = "User #{@showing_user.username}"
@@ -34,4 +36,8 @@ def tree
3436

3537
@tree
3638
end
39+
40+
def invite
41+
@title = "Pass Along an Invitation"
42+
end
3743
end

app/views/settings/index.html.erb

+1-24
Original file line numberDiff line numberDiff line change
@@ -138,28 +138,5 @@
138138
Invite a New User
139139
</div>
140140

141-
<%= form_tag "/invitations", :method => :post do |f| %>
142-
<p>
143-
Invitations are used as a spam-control mechanism and are unlimited.
144-
Persons you invite will be associated with your account in the <a
145-
href="/u">user tree</a> and you may be responsible for them if they cause
146-
problems. Please use your discretion when inviting persons you don't
147-
personally know.
148-
</p>
149-
150-
<div class="boxline">
151-
<%= label_tag :email, "E-mail Address:", :class => "required" %>
152-
<%= text_field_tag :email, "", :size => 30 %>
153-
</div>
154-
155-
<div class="boxline">
156-
<%= label_tag :memo, "Memo to User:", :class => "required" %>
157-
<%= text_field_tag :memo, "", :size => 60 %>
158-
</div>
159-
160-
<div class="boxline">
161-
<p></p>
162-
<%= submit_tag "Send Invitation" %>
163-
</div>
164-
<% end %>
141+
<%= render :partial => "users/invitationform" %>
165142
</div>
+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<p>
2+
Invitations are unlimited, but persons you invite will be associated with your
3+
account in the <a href="/u">user tree</a> and you may be responsible for them
4+
if they cause problems. Please use your discretion when inviting persons you
5+
don't personally know.
6+
</p>
7+
8+
<%= form_tag "/invitations", :method => :post do |f| %>
9+
<% if defined?(return_home) && return_home %>
10+
<%= hidden_field_tag :return_home, 1 %>
11+
<% end %>
12+
13+
<div class="boxline">
14+
<%= label_tag :email, "E-mail Address:", :class => "required" %>
15+
<%= text_field_tag :email, "", :size => 30 %>
16+
</div>
17+
18+
<div class="boxline">
19+
<%= label_tag :memo, "Memo to User:", :class => "required" %>
20+
<%= text_field_tag :memo, "", :size => 60 %>
21+
</div>
22+
23+
<div class="boxline">
24+
<p></p>
25+
<%= submit_tag "Send Invitation" %>
26+
</div>
27+
<% end %>
28+

app/views/users/invite.html.erb

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<div class="box wide">
2+
<div class="legend">
3+
Pass Along an Invitation
4+
</div>
5+
6+
<p>
7+
This community can only grow when members invite new users, just as <a
8+
href="/u/<%= @user.invited_by_user.try(:username) %>"><%=
9+
@user.invited_by_user.try(:username) %></a> invited you. Take a moment and
10+
invite someone you know.
11+
</p>
12+
13+
<%= render :partial => "users/invitationform",
14+
:locals => { :return_home => true } %>
15+
16+
or
17+
18+
<p>
19+
<%= button_to "Skip", "/" %>
20+
</p>
21+
</div>

config/routes.rb

+5-3
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,17 @@
6969
get "/u" => "users#tree"
7070
get "/u/:id" => "users#show"
7171

72+
get "/users/invite" => "users#invite"
73+
7274
get "/settings" => "settings#index"
7375
post "/settings" => "settings#update"
74-
76+
7577
get "/filters" => "filters#index"
7678
post "/filters" => "filters#update"
77-
79+
7880
post "/invitations" => "invitations#create"
7981
get "/invitations/:invitation_code" => "signup#invited"
80-
82+
8183
get "/moderations" => "moderations#index"
8284
get "/moderations/page/:page" => "moderations#index"
8385
end

0 commit comments

Comments
 (0)