Advertisement
Advertisement
| 08.19.2008 at 10:12AM PDT, ID: 23660399 | Points: 500 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: |
application.html.erb in myrubyapp/app/views/layouts
<!DOCTYPE HTML PUBLIC "-//W3C/DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xthml1-strict.dtd">
<html>
<head>
<title><%= @title %></title>
<%= stylesheet_link_tag "site" %>
</head>
<body>
<div id="whole_page">
<div id="header">ThingsTaDo.com</div>
<div id="nav">
<%= link_to_unless_current "Home", :action => "index"%> |
<%= link_to_unless_current "About Us", :action => "about"%> |
<%= link_to_unless_current "Help", :action => "help" %> |
<%= link_to_unless_current "Register", :action => "register",
:controller => "user" %>
</div>
<div id="content">
<%= @content_for_layout %>
</div>
<% if flash[:notice] -%>
<div id=:"notice"><%= flash[:notice] %></div>
<% end -%>
<% if ENV["RAILS_ENV"] == "development" %>
<% debug(params) %>
<% end %>
</div>
</body>
</html>
_________________________________________________________________________________________________________
Register.html.erb in myrubyapp/app/views/sites
<h2>Register</h2>
<% form_for :user do |form| %>
<fieldset>
<legend>Enter Your Details</legend>
<% error_messages_for "user" %>
<div class="form_row">
<label for "screen_name">Screen Name:</label>
<%= form.text_field :screen_name,
:size => User::SCREEN_NAME_SIZE,
:maxlength => User::SCREEN_NAME_MAX_LENGTH %>
</div>
<div class="form_row">
<label for "email">Email:</label>
<%= form.text_field :email,
:size => User::EMAIL_SIZE,
:maxlength => User::EMAIL_MAX_LENGTH %>
</div>
<div class="form_row">
<label for "password">Password:</label>
<%= form.password_field :password,
:size => User::PASSWORD_SIZE,
:maxlength => User::PASSWORD_MAX_LENGTH %>
</div>
<div class="form_row">
<%= submit_tag "Register!", :class => "submit" %>
</div>
</fieldset>
<% end %>
___________________________________________________________________
user controller located in myrubyapp/app/controller/user_controller.rb
class UserController < ApplicationController
def index
end
def register
@title = "Register"
if request.post? and params[:user]
@user = User.new(params[:user])
if @user.save
flash[:notice] = "User #{user.screen_name} created!"
redirect_to :action => "index"
end
end
end
end
|