Skip to content

Commit

Permalink
Merge pull request #16 from Lucash2022/user-photo
Browse files Browse the repository at this point in the history
Allow user to add a photo
  • Loading branch information
Lucas-Erkana authored Jul 11, 2023
2 parents fdde8a7 + 46957d5 commit 2492615
Show file tree
Hide file tree
Showing 15 changed files with 216 additions and 29 deletions.
152 changes: 139 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,150 @@
# README
# 📗 Table of Contents

This README would normally document whatever steps are necessary to get the
application up and running.
- [📗 Table of Contents](#-table-of-contents)
- [📖 TDD Project ](#-oop-school-library--)
- [🛠 Built With ](#-built-with-)
- [Tech Stack ](#tech-stack-)
- [Key Features](#key-features)
- [🚀 Live Demo](#live-demo)
- [📽️ Video Presentation](#video)
- [💻 Getting Started ](#-getting-started-)
- [Prerequisites](#prerequisites)
- [Setup](#setup)
- [Install](#install)
- [Usage](#usage)
- [Authors ](#authors-)
- [🔭 Future Features ](#-future-features-)
- [🤝 Contributing ](#-contributing-)
- [⭐️ Show your support ](#️-show-your-support-)
- [🙏 Acknowledgments ](#-acknowledgments-)
- [📝 License ](#-license-)

Things you may want to cover:
## 📖 SpendSmart<a name="about-project"></a>
SpendSmart is a web-based budgeting application built using Ruby on Rails and PostgreSQL. With SpendSmart, users can effortlessly track their income and expenses, gaining full control over their finances. 💰💼

* Ruby version
## 🛠 Built With <a name="built-with"></a>

* System dependencies
## Tech Stack <a name="tech-stack"></a>

* Configuration
- [Ruby](https://www.ruby-lang.org/en/)
- [Ruby on Rails](https://rubyonrails.org/)
- [PostgreSQL](https://www.postgresql.org/)

* Database creation
## Key Features

* Database initialization
- [ ] **Register an account**
- [ ] **Login registered account**
- [ ] **Create categories and transactions**
- [ ] **Upload Profile photo**

* How to run the test suite
<p align="right">(<a href="#readme-top">back to top</a>)</p>

* Services (job queues, cache servers, search engines, etc.)
### 🚀 Live Demo <a name="live-demo"></a>

* Deployment instructions
- [SpendSmart](#)

* ...
### 📽️ Video Presentation <a name="video"></a>

[Video Presentation ] (https://www.loom.com/share/5d571397947b49f0a677c66a047801e0?sid=14c5b6cf-58cf-45bb-bf08-e4a63cb61bbb)-Powered by Loom

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## 💻 Getting Started <a name="getting-started"></a>

To get a local copy up and running, follow these steps.

## Prerequisites

In order to run this project you need to install the following on your machine:
- [Ruby](https://www.ruby-lang.org/en/)
- [Ruby on Rails](https://rubyonrails.org/)
- [PostgreSQL](https://www.postgresql.org/)

## Setup

Clone this repository to your desired folder:

Example commands:

- Clone this repository using GitBash or the command Terminal:

```sh
git clone https://github.com/Lucash2022/SpendSmart.git

cd SpendSmart
```

## Install

- Inside the project directory, install the project's dependencies:

```sh
bundle install
```

- Create the app's database

```sh
rails db:create
```

- Setup the app's database

```sh
rails db:setup
```
## Usage

```sh
rails server
```
- Runs the app local server


## Authors <a name="authors"></a>

👤 **Lucas Erkana**

- GitHub: [@Lucash2022](https://github.com/Lucash2022)
- Twitter: [@Lucas_David_22](https://twitter.com/@Lucas_David_22)
- LinkedIn: [Lucas Erkana](https://www.linkedin.com/in/lucas-erkana/)
- Frontend Mentor - [@PLucash2022](https://www.frontendmentor.io/profile/Lucash2022)

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## 🔭 Future Features <a name="future-features"></a>

- [ ] **Delete and edit transactions**
- [ ] **User profile settings**

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## 🤝 Contributing <a name="contributing"></a>

Contributions, issues, and feature requests are welcome!

Feel free to check the [issues page](https://github.com/Lucash2022/SpendSmart/issues).

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## ⭐️ Show your support <a name="support"></a>

If you like this project please leave a star. Thank you 🙏

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## 🙏 Acknowledgments <a name="acknowledgements"></a>

- I would like to thank Microverse for the great project idea. ❤️
- Credit goes to [Gregoire Vella on Behance](https://www.behance.net/gregoirevella) whose original design was used.

Icons were used from [Flaticon](https://www.flaticon.com/)

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## 📝 License <a name="license"></a>

This project is [MIT](./LICENSE) licensed.


<p align="right">(<a href="#readme-top">back to top</a>)</p>
10 changes: 10 additions & 0 deletions app/assets/stylesheets/mobile_nav.css
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@
padding: 20px;
}

.avatar-img {
width: 200px; /* Adjust the width to your desired size */
height: 210px; /* Adjust the height to your desired size */
}

.rounded-circle {
border-radius: 50%; /* Make the image circular by setting border-radius to 50% */
overflow: hidden; /* Hide any content that exceeds the circular boundaries */
}

.profile-info-container p {
margin-top: 5px;
text-align: center;
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# app/controllers/registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
private

def sign_up_params
params.require(:user).permit(:name, :email, :password, :password_confirmation, :photo)
end
end
6 changes: 5 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def edit; end
# POST /users or /users.json
def create
@user = User.new(user_params)
@user.photo = params[:user][:photo]
puts "Photo URL: #{params[:user][:photo]}"
puts "User Photo: #{@user.photo}"
puts "User: #{@user}"

respond_to do |format|
if @user.save
Expand Down Expand Up @@ -64,6 +68,6 @@ def set_user

# Only allow a list of trusted parameters through.
def user_params
params.require(:user).permit(:name)
params.require(:user).permit(:name, :email, :password, :password_confirmation, :photo)
end
end
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ class User < ApplicationRecord

has_many :categories, foreign_key: 'author_id'
has_many :entities, foreign_key: 'author_id'

attribute :photo, :string
validates :name, presence: true, length: { maximum: 50 }
end
3 changes: 3 additions & 0 deletions app/views/devise/registrations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
<%= f.label :name %>
<%= f.text_field :name, autofocus: true, placeholder: "Full name", required: true %>
<%= f.label :photo %>
<%= f.text_field :photo, placeholder: "Photo URL", required: false %>
<%= f.label :email %>
<%= f.email_field :email, autocomplete: "email", placeholder: "Email", required: true %>
Expand Down
18 changes: 12 additions & 6 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@
<div id="mobile-nav-container">
<button id="close-mobile-nave"><i class="fa-solid fa-xmark"></i></button>
<!-- Mobile navigation menu -->
<div class="profile-info-container ">
<div class="profile-img">
<i class="fa-solid fa-user"></i>
</div>
<p><%= current_user.name.split(' ').first %></p>
</div>
<div class="profile-info-container">
<div class="profile-img">
<% if user_signed_in? && current_user.photo.present? %>
<%= image_tag current_user.photo, class: "avatar-img rounded-circle" %>
<% else %>
<i class="fa-solid fa-user"></i>
<% end %>
</div>
<p><%= current_user.name.split(' ').first %></p>
</div>


<ul id="mobile-nav-menu">
<!-- Add your navigation links here -->
<li class="nav-link"><%= link_to "Settings", '' %></li>
Expand Down
8 changes: 8 additions & 0 deletions bin/render-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
# exit on error
set -o errexit

bundle install
bundle exec rake assets:precompile
bundle exec rake assets:clean
bundle exec rake db:migrate
4 changes: 1 addition & 3 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,4 @@ test:
#
production:
<<: *default
database: SpendSmart_production
username: SpendSmart
password: <%= ENV["SPENDSMART_DATABASE_PASSWORD"] %>
url: <%= ENV['DATABASE_URL'] %>
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? || ENV['RENDER'].present?

# Compress CSS using a preprocessor.
# config.assets.css_compressor = :sass
Expand Down
4 changes: 2 additions & 2 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
workers ENV.fetch("WEB_CONCURRENCY") { 4 }

# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
# preload_app!
preload_app!

# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Rails.application.routes.draw do
devise_for :users
devise_for :users, controllers: { registrations: 'registrations' }

get '/splash', to: 'splashes#index'

Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20230711111807_add_photo_to_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPhotoToUsers < ActiveRecord::Migration[7.0]
def change
add_column :users, :photo, :string
end
end
3 changes: 2 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions render.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
databases:
- name: spendsmart
databaseName: spendsmart
user: spendsmart_user

services:
- type: web
name: spendsmart
runtime: ruby
buildCommand: "./bin/render-build.sh"
startCommand: "bundle exec puma -C config/puma.rb"
envVars:
- key: DATABASE_URL
fromDatabase:
name: spendsmart
property: connectionString
- key: RAILS_MASTER_KEY
sync: false

0 comments on commit 2492615

Please sign in to comment.