Permalink
Browse files

Include user registration in the example app.

  • Loading branch information...
1 parent bc9b087 commit dd9a55eb971459cbf2d5e5ff8d17ce12049a0806 @brandonaaron brandonaaron committed Dec 15, 2010
Showing with 39 additions and 1 deletion.
  1. +14 −1 example/application.rb
  2. +3 −0 example/views/create_user.erb
  3. +22 −0 example/views/new_user.erb
View
@@ -18,6 +18,20 @@
get('/') { erb(:home) }
+get '/users/new' do
+ @user = User.new
+ erb :new_user
+end
+
+post '/users/create' do
+ @user = User.create(params)
+ if @user.save
+ erb :create_user
+ else
+ erb :new_user
+ end
+end
+
#================================================================
# Register applications
@@ -79,7 +93,6 @@
redirect @auth.redirect_uri
end
-
#================================================================
# Domain API
@@ -0,0 +1,3 @@
+<h3>New User Created</h3>
+
+<p>Your username is: <%= @user.username %></p>
View
@@ -0,0 +1,22 @@
+<h3>Register a User</h3>
+
+<% if @user.errors.any? %>
+ <ul class="errors">
+ <% @user.errors.full_messages.each do |message| %>
+ <li><%= message %></li>
+ <% end %>
+ </ul>
+<% end %>
+
+<form method="post" action="/users/create">
+ <fieldset>
+ <label for="name">Username</label>
+ <input type="text" name="username" id="username">
+ </fieldset>
+
+ <fieldset>
+ <input type="submit" value="Register">
+ </fieldset>
+</form>
+
+

0 comments on commit dd9a55e

Please sign in to comment.