parent
014c15fe4e
commit
09eda4f4e0
@ -1,2 +1,25 @@
|
||||
class UsersController < ApplicationController
|
||||
def index
|
||||
@users = User.all
|
||||
end
|
||||
def new
|
||||
@user = User.new
|
||||
end
|
||||
def show
|
||||
@user = User.find(params[:id])
|
||||
end
|
||||
def create
|
||||
@user = User.new(user_params)
|
||||
if @user.save
|
||||
redirect_to @user, notice: "Thanks for signing up!"
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(:name, :email, :password, :password_confirmation)
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,17 @@
|
||||
<%= form_with(model: user) do |f| %>
|
||||
<%= render "shared/errors", object: user %>
|
||||
|
||||
<%= f.label :name %>
|
||||
<%= f.text_field :name, autofocus: true %>
|
||||
|
||||
<%= f.label :email %>
|
||||
<%= f.email_field :email %>
|
||||
|
||||
<%= f.label :password %>
|
||||
<%= f.password_field :password %>
|
||||
|
||||
<%= f.label :password_confirmation, "Confirm Password" %>
|
||||
<%= f.password_field :password_confirmation %>
|
||||
|
||||
<%= f.submit %>
|
||||
<% end %>
|
@ -0,0 +1,10 @@
|
||||
<h1><%= pluralize(@users.size, "User") %></h1>
|
||||
<ul class="users">
|
||||
<% @users.each do |user| %>
|
||||
<li>
|
||||
<%= link_to user.name, user %>
|
||||
created
|
||||
<%= time_ago_in_words(user.created_at) %> ago
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
@ -0,0 +1,3 @@
|
||||
<h1>Sign Up</h1>
|
||||
|
||||
<%= render "form", user: @user %>
|
@ -0,0 +1,4 @@
|
||||
<section class="user">
|
||||
<h1><%= @user.name %></h1>
|
||||
<h2><%= mail_to(@user.email) %></h2>
|
||||
</section>
|
Loading…
Reference in new issue