Skip to content

Commit

Permalink
Merge pull request #6 from NenehB/personal_details
Browse files Browse the repository at this point in the history
Personal details
  • Loading branch information
NenehB authored Nov 30, 2021
2 parents 9f2b5f9 + 509bcf2 commit e65ac58
Show file tree
Hide file tree
Showing 12 changed files with 253 additions and 35 deletions.
2 changes: 1 addition & 1 deletion app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def update
redirect_to posts_url
end


private

def post_params
Expand Down
9 changes: 7 additions & 2 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ def create
render "new"
end
end


# def index
# p '+++++'
# @user = User.find_by(first_name: params[:first_name])
# p '+++++'
# end
def destroy
session[:user_id] = nil
redirect_to '/posts#index', notice: "Logged out!"
redirect_to root_url, notice: "Logged out!"
end

end
10 changes: 9 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@ def create
end
end

def show

end

def index

end

private
def user_params
params.require(:user).permit(:first_name, :surname, :email, :password, :password_confirmation, :gender, :dob)
p params.require(:user).permit(:first_name, :surname, :email, :password, :password_confirmation, :gender, :dob)
end

end
6 changes: 6 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
<!DOCTYPE html>
<html>
<head>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<%= favicon_link_tag asset_path('favicon.ico') %>

<title>Acebook</title>
<%= csrf_meta_tags %>

Expand Down
40 changes: 24 additions & 16 deletions app/views/posts/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,27 @@
</div>
</nav>

<ul class="nav justify-content-end">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Profile</a>
</li>
<li class="nav-item">

<ul class="nav justify-content-end">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#home">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/users/index">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Settings</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Sign Out</a>
</li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" <%= link_to "Log Out", logout_path %></a>
</li>
</ul>

<p1 class="h2 offset-1"> <%= link_to new_post_path do %>
Write a post
<% end %> </p1>



<div class="container">
<div class = "row">
Expand All @@ -51,6 +58,7 @@
</div>
</div>
</div>

</div>
</div>

Expand All @@ -59,9 +67,9 @@
</div>

<% @posts.each do |post| %>
<div class="container">
<div class ="row offset-4">
<div class="card" style="width: 30rem;">
<div class="container">
<div class ="row offset-2">
<div class="card shadow p-3 mb-5 bg-white rounded" style="width: 100rem;">
<div class="card-body">
<h5 class="card-title">Users name</h5>
<h6 class="card-subtitle mb-2 text-muted"><%= post.created_at %></h6>
Expand Down
141 changes: 129 additions & 12 deletions app/views/sessions/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,130 @@
<h1>Log In</h1>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet">
<title>Bootstrap Sign up Form with Icons</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
body {
color: #999;
background: #f5f5f5;
font-family: 'Roboto', sans-serif;
}
.form-control, .form-control:focus, .input-group-addon {
border-color: #e1e1e1;
}
.form-control, .btn {
border-radius: 3px;
}
.signup-form {
width: 390px;
margin: 0 auto;
padding: 30px 0;
}
.signup-form form {
color: #999;
border-radius: 3px;
margin-bottom: 15px;
background: #fff;
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
padding: 30px;
}
.signup-form h2 {
color: #333;
font-weight: bold;
margin-top: 0;
}
.signup-form hr {
margin: 0 -30px 20px;
}
.signup-form .form-group {
margin-bottom: 20px;
}
.signup-form label {
font-weight: normal;
font-size: 13px;
}
.signup-form .form-control {
min-height: 38px;
box-shadow: none !important;
}
.signup-form .input-group-addon {
max-width: 42px;
text-align: center;
}
.signup-form input[type="checkbox"] {
margin-top: 2px;
}
.signup-form .btn{
font-size: 16px;
font-weight: bold;
background: #19aa8d;
border: none;
min-width: 140px;
}
.signup-form .btn:hover, .signup-form .btn:focus {
background: #179b81;
outline: none;
}
.signup-form a {
color: #fff;
text-decoration: underline;
}
.signup-form a:hover {
text-decoration: none;
}
.signup-form form a {
color: #19aa8d;
text-decoration: none;
}
.signup-form form a:hover {
text-decoration: underline;
}
.signup-form .fa {
font-size: 21px;
}
.signup-form .fa-paper-plane {
font-size: 18px;
}
.signup-form .fa-check {
color: #fff;
left: 17px;
top: 18px;
font-size: 7px;
position: absolute;
}
</style>
</head>
<body>
<div class="signup-form">
<%= form_tag sessions_path do %>
<h2>Sign in</h2>
<p>Please fill in this form to sign in!</p>
<hr>
<div class="field">
<span><i class="fa fa-paper-plane"></i></span>
<%= label_tag :email %>
<%= text_field_tag :email, params[:email] %>
</div>

<div class="field">
<span ><i class="fa fa-lock"></i></span>
<%= label_tag :password %>
<%= password_field_tag :password %>
</div>
<br>
<div class="actions" ><%= submit_tag "Log In" %></div>
<br>
<hr>
Dont have an account? Click to <%= link_to "Sign Up", sign_up_path %>
<% end %>
</div>
</body>
</html>

<%= form_tag sessions_path do %>
<div class="field">
<%= label_tag :email %><br />
<%= text_field_tag :email, params[:email] %>
</div>
<div class="field">
<%= label_tag :password %><br />
<%= password_field_tag :password %>
</div>
<div class="actions"><%= submit_tag "Log In" %></div>
<% end %>
Empty file added app/views/users/index.html.erb
Empty file.
5 changes: 4 additions & 1 deletion app/views/users/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@
<br>
<div class="field">
<%= f.label :Date_of_Birth %> <br>
<%= f.date_select :dob, :start_year=>1950,:end_year=>2050%>
<%= f.date_select :dob, :start_year => Time.now.year - 50,
:end_year => Time.now.year + 5,
:order => [:day, :month, :year],
:include_blank => true%>
</div>

<br>
Expand Down
64 changes: 64 additions & 0 deletions app/views/users/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">

</head>
<body>

<nav class="navbar navbar-dark bg-primary">
<div class="container-fluid">
<a class="navbar-brand">Acebook</a>
<form class="d-flex">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</nav>

<ul class="nav justify-content-end">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="/posts">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/users/index">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Settings</a>
</li>
<li class="nav-item">
<a class="nav-link" <%= link_to "Log Out", logout_path %></a>
</li>
</ul>


<br>
</div>
</div>
</div>
</div>

<div class="container ">
<div class ="row offset-2">
<div class="card shadow p-3 mb-5 bg-white rounded" style="width: 100rem;">
<div class="card-body ">
<h3> Personal Detail </h3>
<p>Name: <%= current_user.first_name %> </p>
<p>Surname: <%= current_user.surname %> </p>
<p>Email: <%= current_user.email %> </p>
<p>Gender: <%= current_user.gender %> </p>
<p>Date of birth: <%= current_user.dob %> </p>
</div>
</div>

</div>
</div>

</div>
</body>
</html>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
get 'login', to: 'sessions#new', as: 'login'
get 'sign_up', to: 'users#new', as: 'sign_up'
get 'logout', to: 'sessions#destroy', as: 'logout'
root to: 'sessions#new'
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
resources :sessions
resources :users
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20211130115933_changing_dob_to_date.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ChangingDobToDate < ActiveRecord::Migration[6.0]
def change
change_column :users, :dob, :date, using: 'dob::date'
end
end
5 changes: 3 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2021_11_30_115933) do


ActiveRecord::Schema.define(version: 2021_11_29_182941) do


# These are extensions that must be enabled in order to support this database
Expand Down Expand Up @@ -62,7 +63,7 @@
t.string "email"
t.string "password_digest"
t.string "gender"
t.string "dob"
t.date "dob"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
Expand Down

0 comments on commit e65ac58

Please sign in to comment.