Skip to content
This repository has been archived by the owner on Jul 4, 2018. It is now read-only.

Commit

Permalink
More users stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel.hahn authored and daniel.hahn committed Feb 23, 2012
1 parent 19e5a4a commit 36c0543
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/assets/stylesheets/application.css
Expand Up @@ -21,4 +21,8 @@ body{
h1{
font-size:1.8em;
color:#333;
}
}

td{
padding: 10px;
}
18 changes: 18 additions & 0 deletions app/controllers/users_controller.rb
@@ -1,2 +1,20 @@
class UsersController < ApplicationController

def index
@users = User.all
end

def new
@user = User.new
end

def create
@user = User.new(params[:user])
if(@user.save)
redirect_to users_path
else
render :new
end
end

end
4 changes: 4 additions & 0 deletions app/views/users/_user.html.erb
@@ -0,0 +1,4 @@
<tr>
<td><%= user.name %></td>
<td><%= user.email %></td>
<tr>
5 changes: 5 additions & 0 deletions app/views/users/index.html.erb
@@ -0,0 +1,5 @@
<table>
<%= render @users %>
<table>

<%= link_to "Create new", new_user_path %>
9 changes: 9 additions & 0 deletions app/views/users/new.html.erb
@@ -0,0 +1,9 @@
<%= form_for @user do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= @user.errors.get(:name).join(', ') %>
<%= f.label :email %>
<%= f.text_field :email %>
<%= @user.errors.get(:email).join(', ') %>
<%= f.submit %>
<% end %>
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -3,6 +3,7 @@
# first created -> highest priority.

resources :todos
resources :users

# Sample of regular route:
# match 'products/:id' => 'catalog#view'
Expand Down

0 comments on commit 36c0543

Please sign in to comment.