onboarding process from anon account to real account

This commit is contained in:
Andrew Brown 2013-03-10 22:40:48 -05:00
parent 27c060cba9
commit e17cf877ed
5 changed files with 25 additions and 2 deletions

View File

@ -41,7 +41,8 @@ class UsersController < ApplicationController
respond_to do |format|
if @user.save
session[:user] = @user.id
format.html { redirect_to dashboard_path, notice: 'You have been logged in to a temporary account that will delete itself (and everything you create with it!) as soon as you log out.' }
session[:anon_user] = true
format.html { redirect_to dashboard_path }
format.json { render json: @user, status: :created }
else
format.html { render action: "new" }
@ -57,6 +58,7 @@ class UsersController < ApplicationController
respond_to do |format|
if @user.update_attributes(params[:user])
session[:anon_user] = false
format.html { redirect_to homepage_path, notice: 'Successfully updated.' }
format.json { head :no_content }
else

View File

@ -25,6 +25,17 @@ class User
}
end
def content_count
[
characters.length,
equipment.length,
languages.length,
locations.length,
magics.length,
universes.length
].sum
end
def characters
Character.where(user_id: id)
end

View File

@ -0,0 +1,9 @@
<% if session[:anon_user] and session[:user] and User.find(session[:user]).content_count > 0 %>
<div class="navbar" style="padding: 12px; margin-top: -20px; background: #ccffee; border-bottom: 1px solid #bbeeff; text-align: center;">
<div class="container">
You are currently using an anonymous account. In order to save the brilliant things you have created with it, please <a href="/account">click here</a> to give yourself a username and password.
</div>
</div>
<% end %>

View File

@ -75,4 +75,4 @@
</div>
</div>
</div>
</div>
</div>

View File

@ -8,6 +8,7 @@
</head>
<body>
<%= render 'layouts/navbar' %>
<%= render 'layouts/anon_notice' %>
<div class="container">
<%= render 'layouts/notices' %>