Skip to content

Instantly share code, notes, and snippets.

@shosanna
Created March 19, 2014 10:51
Show Gist options
  • Save shosanna/9639362 to your computer and use it in GitHub Desktop.
Save shosanna/9639362 to your computer and use it in GitHub Desktop.
class ContactsController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new
@user.first_name = params[:first_name]
@user.last_name = params[:last_name]
@user.phone = params[:phone]
@user.admin = params[:admin]
@user.owner = params[:owner]
@user.save!
redirect_to contacts_index_path
end
def index
@users = User.all
end
end
<h1>User Manager</h1>
<p>Listing all users </p>
<table>
<tr>
<td> First name </td>
<td> Last name </td>
<td> Phone </td>
<td> Sex </td>
<td> Owner </td>
<td> Admin </td>
</tr>
<tr>
<% @users.all do |user| %>
<td> <%= user.first_name %> </td>
<td> <%= user.last_name %> </td>
<td> <%= user.phone %> </td>
<td> <%= user.sex %> </td>
<td> <%= user.owner %> </td>
<td> <%= user.admins %> </td>
<% end %>
</tr>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment