Skip to content

Commit

Permalink
Merge pull request #25 from demesameneshoa/feature/final-touches
Browse files Browse the repository at this point in the history
Issue #14 🎫  Final touches
  • Loading branch information
ITurres authored Dec 22, 2023
2 parents 50942d4 + bc751c6 commit 6f9045e
Show file tree
Hide file tree
Showing 26 changed files with 615 additions and 427 deletions.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Demes Ameneshoa and Arthur Emanuel G. Iturres

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
285 changes: 272 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,283 @@
# README
<a name="readme-top"></a>

This README would normally document whatever steps are necessary to get the
application up and running.
<div align="center">
<img src="app/assets/images/recipes-app-logo-png-large.png" alt="logo" width="350" height="auto" />
<h1><b>My Recipes App</b></h1>
</div>

Things you may want to cover:
---

* Ruby version
<!-- ! TABLE OF CONTENTS -->

* System dependencies
# 📗 Table of Contents

* Configuration
- [📖 About the Project](#about-project)
- [🛠 Built With](#built-with)
- [Tech Stack](#tech-stack)
- [Key Features](#key-features)
- [💻 Getting Started](#getting-started)
- [Prerequisites](#prerequisites)
- [Setup](#setup)
- [Install](#install)
- [Usage](#usage)
- [Run tests](#run-tests)
- [👥 Authors](#authors)
- [🔭 Future Features](#future-features)
- [🤝 Contributing](#contributing)
- [⭐️ Show your support](#support)
- [🙏 Acknowledgements](#acknowledgements)
- [📝 License](#license)

* Database creation
---

* Database initialization
<!-- ! PROJECT DESCRIPTION -->

* How to run the test suite
# 📖 My Recipes app <a name="about-project"></a>

* Services (job queues, cache servers, search engines, etc.)
> This is a web application that allows users to register and start managing recipes. Users can create, edit, and delete recipes. In addition, it is also possible to create a food inventory and take ingredients from it when creating a recipe. The application will also allow you to generate a shopping list based on the recipes you have created and the food items needed to make them.
> For those who do not wish to register, you can see the public recipes posted by other users.
* Deployment instructions
#### Learning objectives

* ...
- Use Ruby gems as a software packages system.
- Install Ruby on Rails framework.
- Understand Rails RESTful design and router.
- Use controllers to handle requests and render empty views.
- Understand Rails naming conventions.
- Use params from browser requests in a safe way.
- Use preprocessed HTML file with embedded Ruby code.
- Use layouts and templates for shared content.
- Use database migration files to maintain database schema.
- Use validations for models.
- Secure app from n+1 problems.
- Understand what ORM is.
- Write SQL queries with ActiveRecord.
- Set up associations between models.
- Build a web app that requires the user to log in.
- Describe the difference between authorization and authentication.
- Use Devise gem for authentication.
- Understand how sessions and cookies can support authentication.
- Write unit tests using Rspec
- Write integration tests with capybara gem

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

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

<ul>
<li>
<a href="https://www.ruby-lang.org/en/">
<img src="https://skillicons.dev/icons?i=ruby"/> Ruby
</a>
</li>
<li>
<a href="https://rubyonrails.org/">
<img src="https://skillicons.dev/icons?i=rails"/> Rails
</a>
</li>
<li>
<a href="https://www.postgresql.org/">
<img src="https://skillicons.dev/icons?i=postgresql"/> PostgreSQL
</a>
</li>
<li>
<a href="https://getbootstrap.com/docs/4.0/getting-started/introduction/">
<img src="https://skillicons.dev/icons?i=bootstrap"/> Bootstrap
</a>
</li>
<li>
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS">
<img src="https://skillicons.dev/icons?i=css"/> CSS
</a>
</li>
<li>
<a href="https://www.w3schools.com/html/">
<img src="https://skillicons.dev/icons?i=html"/> HTML5
</a>
</li>
</ul>

#### Highlighted Gems

- [Devise](https://github.com/heartcombo/devise/wiki)

---

### :key: Key Features <a name="key-features"></a>

- Users can sign up and log in to the application.
- Users can create, edit, and delete recipes.
- Users can create a food inventory and take ingredients from it when creating a recipe.
- Users can generate a shopping list based on the recipes they have created and the food items needed to make them.

---

<!-- ! GETTING STARTED -->

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

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

### Prerequisites

To run this project you need:

- Have Ruby installed. If you need to install Ruby, follow the instructions on the [official page](https://www.ruby-lang.org/en/documentation/installation/).

### Setup

Clone this repository to your desired folder:

Example commands:

- With SSH:

```bash
cd my-folder
git clone [email protected]:demesameneshoa/recipes-app.git
```

- With HTTPS:

```bash
cd my-folder
git clone https://github.com/demesameneshoa/recipes-app.git
```

- With GitHub CLI:

```bash
cd my-folder
gh repo clone demesameneshoa/recipes-app
```

### Install <a name="install"></a>

Go to the project directory:

```bash
cd recipes-app
```

Before running the program, verify that you have Ruby on Rails installed on your OS by running the following command:

```bash
rails --version
```

It should show you the version of Ruby On Rails ​​installed. If this does not happen and only an error message is displayed, you should verify your installation or install Ruby on Rails from scratch.

[Download and Install Ruby on Rails](https://guides.rubyonrails.org/getting_started.html)

Once you have verified that you have Ruby on Rails installed, run the following command to install the necessary gems:

```bash
bundle install
```

After installing the gems, run the following command to create the database:

```bash
rails db:create
```

Then run the following command to migrate the database:

```bash
rails db:migrate
```

### Usage <a name="usage"></a>

Run the following command inside the project folder to start the application:

```bash
rails s
```

This will start the application on your local server. You can now open your browser and go to http://localhost:3000/ to see the application running.

### Run tests <a name="run-tests"></a>

To execute the tests, run the following command inside the project folder (root):

```bash
bundle exec rspec
```

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

---

<!-- ! AUTHORS -->

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

👤 **Demes Ameneshoa**

- GitHub: [@demesameneshoa](https://github.com/demesameneshoa)
- LinkedIn: [@demesameneshoa](https://www.linkedin.com/in/demesameneshoa/)

👤 **Arthur Iturres**

- GitHub: [@ITurres](https://github.com/ITurres)
- LinkedIn: [Arthur Emanuel G. Iturres](https://www.linkedin.com/in/arturoemanuelguerraiturres/)
- Angellist / Wellfound: [Arturo (Arthur) Emanuel Guerra Iturres](https://wellfound.com/u/arturo-arthur-emanuel-guerra-iturres)
- Youtube: [Arturo Emanuel Guerra Iturres - Youtube Channel](https://www.youtube.com/channel/UC6GFUFHOtBS9mOuI8EJ6q4g)
- Portfolio: [Arthur Iturres - Portfolio](https://iturres.github.io/iturres-reactive-portfolio/)

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

---

<!-- ! FUTURE FEATURES -->

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

- [ ] Allow users to upload images for their recipes.

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

---

<!-- ! CONTRIBUTING -->

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

Contributions, issues, and feature requests are welcome!

Feel free to check the [issues page](https://github.com/demesameneshoa/recipes-app/issues).

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

---

<!-- ! SUPPORT -->

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

Give a ⭐ if you liked this project!

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

---

<!-- ! ACKNOWLEDGEMENTS -->

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

I thank the **Code Reviewers** for their advice and time 🏆

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

---

<!-- ! LICENSE -->

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

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

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

---
5 changes: 3 additions & 2 deletions app/controllers/foods_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def create
def update
respond_to do |format|
if @food.update(food_params)
format.html { redirect_to food_url(@food), notice: 'Food was successfully updated.' }
flash[:info] = 'Food was successfully updated.'
format.html { redirect_to food_url(@food) }
format.json { render :show, status: :ok, location: @food }
else
format.html { render :edit, status: :unprocessable_entity }
Expand All @@ -53,7 +54,7 @@ def destroy
@food.destroy!

respond_to do |format|
flash[:success] = 'Food was successfully destroyed.'
flash[:info] = 'Food was successfully removed.'
format.html { redirect_to foods_url }
format.json { head :no_content }
end
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/recipe_foods_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ def create
def update
respond_to do |format|
if @recipe_food.update(recipe_food_params)
flash[:success] = 'Recipe was successfully updated.'
flash[:info] = 'Recipe was successfully updated.'
format.html { redirect_to recipe_food_path(@recipe_food) }
else
flash[:danger] = 'Recipe was not updated.'
flash[:danger] = 'Coulnd\'t update recipe...'
format.html { render :edit, status: :unprocessable_entity }
end
end
Expand Down
17 changes: 12 additions & 5 deletions app/controllers/recipes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def public_index

# GET /recipes/1 or /recipes/1.json
def show
unless user_signed_in?
flash[:warning] = 'Please Sing in or Sign up to see full details! 😊'
redirect_to root_path
end

@recipe = Recipe.includes(:recipe_foods).find(params[:id])
@recipe_food = @recipe.recipe_foods.includes(:food)
end
Expand All @@ -33,9 +38,8 @@ def create
@recipe.user = current_user
respond_to do |format|
if @recipe.save
format.html { redirect_to recipes_path, notice: 'Recipe was successfully created.' }
# format.html { redirect_to recipe_url(@recipe), notice: 'Recipe was successfully created.' }
# format.json { render :show, status: :created, location: @recipe }
flash[:success] = 'Recipe was successfully created.'
format.html { redirect_to recipes_path }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @recipe.errors, status: :unprocessable_entity }
Expand All @@ -47,9 +51,11 @@ def create
def update
respond_to do |format|
if @recipe.update(recipe_params)
format.html { redirect_to recipe_url(@recipe), notice: 'Recipe was successfully updated.' }
flash[:info] = 'Recipe was successfully updated.'
format.html { redirect_to recipe_url(@recipe) }
format.json { render :show, status: :ok, location: @recipe }
else
flash[:danger] = 'Coulnd\'t update recipe...'
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @recipe.errors, status: :unprocessable_entity }
end
Expand All @@ -63,7 +69,8 @@ def destroy
@recipe.recipe_foods.destroy_all

respond_to do |format|
format.html { redirect_to recipes_url, notice: 'Recipe was successfully deleted.' }
flash[:info] = 'Recipe was successfully deleted.'
format.html { redirect_to recipes_url }
format.json { head :no_content }
end
end
Expand Down
Loading

0 comments on commit 6f9045e

Please sign in to comment.