Skip to content

This app allows you to upload your cat photo and vote for other photos, using IBM cloud using active storage

License

Notifications You must be signed in to change notification settings

redacuve/my-cat-photos

Repository files navigation

Version License: GPLv3 Twitter: redacuve


Project: My Cat Photos


Explore the repo »
Request Feature

Table of Contents

About The Project

This is the full app using my initial code from my tutorial "A Guide for Uploading and Showing Images Trough IBM CLOUD with RAILS 6". If you only want to check the code for the tutorial, you can find the repo here.

My Cat Photos app allows you to like photos of cats. You only can vote once, you don't need to register to vote, it has a very simple logic for the voting, but it works.

You can upload your Cat Photo with ease, and your photos can be voted on by anyone. Have fun looking at lots of cats photos.

Built With

Getting Started

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

Clone or fork the repo [git@github.com:redacuve/my-cat-photos.git]

Note* Ruby and Rails needs to be installed to run the code, check here and here for further steps. Also you need to setup your own IBM Cloud or AWS keys on the credentials to work properly.

Attention* If you want to setup this project locally you need to add YOUR OWN CLOUD KEYS on credientials.yml, to edit this file you NEED to run this command:

 $ EDITOR='nano' rails credentials:edit

note* you must change the editor to your favorite, for example, gedit, vim, geany, kate, kwrite, emacs, etc. Also, you MUST configure the file carrierwave.rb, this file is located at:

.
├── config
│   ├── initializers
│   │   ├── carrierwave.rb

The configuration of this file needs to have YOUR OWN cloud configuration:

How it Works

It uses the carrierwave gem to upload files with ease, carrierwave by default is not able to send the uploaded files to the cloud, to achieve that we need to use the gem fow-aws, this gem allows to us to save the file previously uploaded with carrierwave to the cloud with the protocol S3, IBM cloud uses this protocol, so the configuration is straightforward.

There are two pages for this app, the index page where you can see all of the photos uploaded by anyone and the upload page, here you can upload your photo to be voted.

On the index page you can sort the photos by most voted or by recent photos, also you can vote with the like or dislike buttons if you click like, the total votes for the photo will be increased by 1 and if you click dislike the votes will decrease by one, all of the votes are updating via Vanilla JS, the method votes in the photos controller respond to a js.erb view, so voting for a photo can be done without refreshing the entire index page.

Running the code

  • Navigate to the root directory of the project

  • Run this command on your terminal to install all the needed gems:

    $ bundle install
    
  • Install Yarn

    $ yarn install --check-files
    
  • Create and migrate the database

    $ rails db:create
    $ rails db:migrate
    
  • Add your own credentials for IBM Cloud or AWS

    $ EDITOR='nano' rails credentials:edit
    
  • Run the develpment server with

    $ rails server
    
  • Take a look at the app

    http://127.0.0.1:3000/
    

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project

  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)

  3. Commit your Changes (git commit -m 'Add some AmazingFeature')

  4. Push to the Branch (git push origin feature/AmazingFeature)

  5. Open a Pull Request

License

This project is under the GNU Public License V3. For more information see here

Contact

Rey David Cuevas Vela - @redacuve - redacuve@gmail.com -linkedin.com/in/redacuve/

Project Link: github.com/redacuve/my-cat-photos - My Cat Photos.

About

This app allows you to upload your cat photo and vote for other photos, using IBM cloud using active storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published