Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iank-code/inventory-management-rails
https://github.com/iank-code/inventory-management-rails
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/iank-code/inventory-management-rails
- Owner: Iank-code
- Created: 2024-05-17T12:19:36.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-05-19T13:38:38.000Z (6 months ago)
- Last Synced: 2024-05-19T14:37:56.380Z (6 months ago)
- Language: Ruby
- Size: 134 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Product Management Application
This is a Ruby on Rails application for managing products. It includes features such as creating, viewing, editing, and deleting products. The application uses Turbo Streams for real-time updates, allowing changes to be reflected on all connected clients without needing to refresh the page.
## Features
- Create, read, update, and delete products
- Real-time updates using Turbo Streams
- Basic validation for product attributes## Requirements
- Ruby 3.0
- Rails 7.1.3.3
- SQLite3## Getting Started
Follow these instructions to get a copy of the project up and running on your local machine.
### Prerequisites
Ensure you have the following installed:
- Ruby 3.0
- Rails 7.1.3.3
- SQLite3### Installation
1. **Clone the repository:**
```sh
git clone [email protected]:Iank-code/Inventory-Management-Rails.git
cd product_management
```2. **Install dependencies:**
```sh
bundle install
```3. **Set up the database:**
```sh
rails db:migrate
```4. **Precompile asset pipline**
```sh
bundle exec rake assets:precompile
```4. **Run the Rails server:**
```sh
rails server
```5. **Visit the application:**
Open your web browser and navigate to `http://localhost:3000/products`.
## Usage
### Creating a Product
1. Click on the "New Product" link.
2. Fill in the product details (name and price).
3. Click "Create Product" to save the new product.### Viewing Products
Navigate to `http://localhost:3000/products` to see a list of all products.
### Editing a Product
1. Click on the "Edit" link next to the product you want to edit.
2. Update the product details.
3. Click "Update Product" to save the changes.### Deleting a Product
Click on the "Destroy" link next to the product you want to delete. Confirm the action to remove the product.
## Real-Time Updates with Turbo Streams
This application uses Turbo Streams for real-time updates. When a product is created, updated, or deleted, the changes are broadcasted to all connected clients, and the product list is updated without needing to refresh the page.
### Model Setup
The `Product` model broadcasts changes using Turbo Streams:
```ruby
class Product < ApplicationRecord
after_create_commit { broadcast_append_to 'products' }
after_update_commit { broadcast_replace_to 'products' }
after_destroy_commit { broadcast_remove_to 'products' }validates :name, presence: true
validates :price, presence: true, numericality: { greater_than: 0 }
end
```