-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Piotr Suwala
committed
Oct 23, 2016
1 parent
73e24f1
commit 9c945b3
Showing
10 changed files
with
439 additions
and
128 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,27 @@ | ||
class UsersController < ApplicationController | ||
|
||
def show | ||
@user = User.find(params[:id]) | ||
end | ||
|
||
def new | ||
@user = User.new | ||
end | ||
|
||
def create | ||
@user = User.new(user_params) | ||
if @user.save | ||
flash[:success] = "Welcome to the Sample App!" | ||
redirect_to @user | ||
else | ||
render 'new' | ||
end | ||
end | ||
|
||
private | ||
|
||
def user_params | ||
params.require(:user).permit(:name, :email, :password, | ||
:password_confirmation) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,9 @@ | ||
module UsersHelper | ||
end | ||
|
||
# Returns the Gravatar for the given user. | ||
def gravatar_for(user) | ||
gravatar_id = Digest::MD5::hexdigest(user.email.downcase) | ||
gravatar_url = "https://secure.gravatar.com/avatar/#{gravatar_id}" | ||
image_tag(gravatar_url, alt: user.name, class: "gravatar") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<% if @user.errors.any? %> | ||
<div id="error_explanation"> | ||
<div class="alert alert-danger"> | ||
The form contains <%= pluralize(@user.errors.count, "error") %>. | ||
</div> | ||
<ul> | ||
<% @user.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
<% provide(:title, 'Sign up') %> | ||
<h1>Sign up</h1> | ||
<p>This will be a signup page for new users.</p> | ||
|
||
<div class="row"> | ||
<div class="col-md-6 col-md-offset-3"> | ||
<%= form_for(@user) do |f| %> | ||
<%= render 'shared/error_messages' %> | ||
|
||
<%= f.label :name %> | ||
<%= f.text_field :name, class: 'form-control' %> | ||
|
||
<%= f.label :email %> | ||
<%= f.email_field :email, class: 'form-control' %> | ||
|
||
<%= f.label :password %> | ||
<%= f.password_field :password, class: 'form-control' %> | ||
|
||
<%= f.label :password_confirmation, "Confirmation" %> | ||
<%= f.password_field :password_confirmation, class: 'form-control' %> | ||
|
||
<%= f.submit "Create my account", class: "btn btn-primary" %> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<% provide(:title, @user.name) %> | ||
<div class="row"> | ||
<aside class="col-md-4"> | ||
<section class="user_info"> | ||
<h1> | ||
<%= gravatar_for @user %> | ||
<%= @user.name %> | ||
</h1> | ||
</section> | ||
</aside> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
Rails.application.routes.draw do | ||
get 'users/new' | ||
|
||
root 'static_pages#home' | ||
get '/help', to: 'static_pages#help' | ||
get '/about', to: 'static_pages#about' | ||
get '/contact', to: 'static_pages#contact' | ||
get '/signup', to: 'users#new' | ||
resources :users | ||
end |