Commit 827cff4a by Tô Ngọc Ánh

Finsh user signup

parent 6f3c19a3
Pipeline #667 canceled with stages
in 0 seconds
...@@ -160,4 +160,17 @@ input, textarea, select, .uneditable-input { ...@@ -160,4 +160,17 @@ input, textarea, select, .uneditable-input {
input { input {
height: auto !important; height: auto !important;
}
#error_explanation {
color: #f00;
ul {
list-style: none;
margin: 0 0 18px 0;
}
}
.field_with_errors {
@extend .control-group;
@extend .error;
} }
\ No newline at end of file
...@@ -8,11 +8,18 @@ class UsersController < ApplicationController ...@@ -8,11 +8,18 @@ class UsersController < ApplicationController
end end
def create def create
@user = User.new(params[:user]) @user = User.new(user_params)
if @user.save if @user.save
#Handle a successful save flash[:success] = "Welcome to the Sample App"
redirect_to @user
else else
render 'new' render 'new'
end end
end end
private
def user_params
params.require(:user).permit(:name, :email, :password, :password_confirmation)
end
end end
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
<body> <body>
<%= render 'layouts/header' %> <%= render 'layouts/header' %>
<div class="container"> <div class="container">
<% flash.each do |key, value| %>
<div class="alert alert-<%= key %>"><%= value %></div>
<% end %>
<%= yield %> <%= yield %>
<%= render 'layouts/footer' %> <%= render 'layouts/footer' %>
<%= debug(params) if Rails.env.development? %> <%= debug(params) if Rails.env.development? %>
......
<% if @user.errors.any? %>
<div id="error_explanation">
<div class="alert alert-error">
The form contains <%= pluralize(@user.errors.count, "error") %>.
</div>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li>* <%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
\ No newline at end of file
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<div class="row"> <div class="row">
<div class="span6 offset3"> <div class="span6 offset3">
<%= form_for(@user) do |f| %> <%= form_for(@user) do |f| %>
<%= render 'shared/error_messages' %>
<%= f.label :name %> <%= f.label :name %>
<%= f.text_field :name %> <%= f.text_field :name %>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment