/Jokes_catalog

Repository that implements an online joke catalog using Ruby on Rails, following the MVC architecture. It provides CRUD functionality for managing jokes, with routes handling GET, POST, PUT, and DELETE requests. Users can interact with the catalog through a web interface to create, read, update, and delete jokes.

Primary LanguageRuby


Jokes-catalog.png

Jokes Catalog




👁️ About


Jokes Catalog is a Ruby on Rails application that implements a joke catalog with CRUD functionality using RESTful conventions: GET for viewing, POST for creating, PUT for updating, and DELETE for removing jokes.

The app includes pages for listing all jokes, viewing individual jokes, creating new jokes, editing existing jokes, and a home page, all following the MVC architecture.



📝 Learning Objectives


+ Implement a Ruby on Rails application following MVC architecture

+ Create RESTful routes for handling GET, POST, PUT, and DELETE requests

+ Develop CRUD functionality for managing database records

+ Build a user-friendly web interface for interacting with data


💻 Requirements


+ Ruby 3.2.0 (via RubyInstaller on Windows or using rbenv for Linux/Mac)

+ Rails 7.0.4

+ PostgreSQL


📦 Installation


✅ Install Ruby:


  On macOS  

  • Install Homebrew (if not installed):

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

  • Install rbenv, a Ruby version management tool:

brew install rbenv

  • Configure rbenv to add it to your shell:

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc

  • Install Ruby 3.2.0:

rbenv install 3.2.0

  • Set it as the local version for this project:

rbenv local 3.2.0

  • Verify Ruby installation:

ruby -v



  On Windows  

  • Install Ruby via RubyInstaller:

    • Go to the RubyInstaller website

    • Download the desired Ruby version (3.2.0) with Devkit (which includes tools for building native gem extensions)

    • During installation, check the option to add Ruby executables to your PATH

    • After installation, follow the prompt to set up MSYS2, which provides the necessary development tools


  • Verify Ruby installation by checking the correct version:

ruby -v



  On Linux  

  • Install rbenv:

git clone https://github.com/rbenv/rbenv.git ~/.rbenv

  • Configure rbenv to add it to your shell:

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc

  • Install ruby-build, the plugin that helps install Ruby versions:

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

  • Install Ruby 3.2.0:

rbenv install 3.2.0

  • Set Ruby 3.2.0 as the local version for your project:

rbenv local 3.2.0

  • Verify Ruby installation:

ruby -v


✅ Clone the repository:


git clone https://github.com/RazikaBengana/Jokes_catalog.git

  • Navigate into the project directory:

cd Jokes_catalog


✅ Install dependencies:


  • Install the necessary Ruby gems specified in the Gemfile with bundler.
    This ensures that all required libraries are available for the application to run:

gem install bundler

bundle install

  • Install rails to create and run the application framework:

gem install rails


✅ Configure the database:


  • Ensure PostgreSQL is installed and running on your system

  • Open the config/database.yml file and configure it for PostgreSQL

    • Replace any SQLite3 configurations with PostgreSQL settings:

default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: your_postgresql_username
  password: your_postgresql_password
  host: localhost

development:
  <<: *default
  database: jokes_catalog_development

test:
  <<: *default
  database: jokes_catalog_test

production:
  <<: *default
  database: jokes_catalog_production
  username: your_production_username
  password: your_production_password

  • Replace with your actual PostgreSQL credentials:

    • your_postgresql_username
    • your_postgresql_password
    • your_production_username
    • your_production_password


✅ Set up the database:


  • Use the following commands to create the database, run migrations, and seed the database with initial data.
    This prepares the database schema and populates it with any default data needed for the application:

rails db:create
rails db:migrate
rails db:seed


✅ Interact with the database:


  • To open the Rails console for database interaction:

rails console

  • To run a specific migration:

rails db:migrate:up VERSION=20210101010101

  • To rollback the last migration:

rails db:rollback

  • To reset the database:

rails db:reset


  • These steps should help you set up the application and interact with the database effectively.

  • If you encounter any issues, ensure that PostgreSQL is correctly installed and that your database.yml file is properly configured.


⌨️ Basic Usage


  • Start the Rails server:

rails server


  • Use the web interface to create, view, update, and delete jokes.


📌 More Info


Services:


  • No external services are required for this application.


Deployment instructions:


  • This application can be deployed to platforms like Heroku or any other Rails-compatible hosting service.

  • Ensure environment variables are properly set for the production environment.


👤 Authors


Razika Bengana



:octocat: License


Jokes Catalog project has no license specified.





2024