-
Ruby on Rails Framwork. From terminal/cmd:
gem install rails
- Clone 'rails-crud' project to 'your destination'
cd 'your destination'
git clone https://github.com/sfarrukh/rails-crud.git
- Install bundle
cd 'rails-crud'
bundle install
- Change username/password in 'rails-crud/config/database.yml' to match your mysql database username/password:
username: 'your username'
password: 'your password'
- Run migrations for the project to build its tables on sakila database:
rails db:migrate
- rails-crud has 3 environments: admin, staff & public/account. Public does not require login, admin and staff does. Create one from rails console:
rails console
admin = Admin.new()
admin.first_name = <First Name>
admin.last_name = <Last Name>
admin.email = <Email Address>
admin.username = <no less than 8 characters>
admin.password = <your password>
admin.save
staff = Staff.new()
staff.first_name = <First Name>
staff.last_name = <Last Name>
staff.email = <Email Address>
staff.username = <no less than 8 charachters>
staff.password = <your password>
staff.save
- Run Server:
rails server --port:4200
- Open your browser, navigate to:
- 'localhost:4200' for public access
- 'localhost:4200/admin' for admin access & login using admin account created above
- 'localhost:4200/staff' for staff access & login using staff account created above
Rails-Crud project is a sample online rental store, which makes use of sample database sakila with a few table additions.
- Table Name
- Actor
- Address
- Category
- City
- Country
- Customer
- Film
- Film Actor
- Film Category
- Inventory
- Rental
- Admin
- Customer Payment Info
- Rental Pending
- Staff
Tables are inter-connected through foreign keys or through other tables, and those connections are defined in project's app/models:
Table 1 connects | Table 2 | through table | through foreign key |
---|---|---|---|
actor | film | film_actor | |
film | category | film_category | |
film | inventory | film_id | |
film | rental | inventory | |
film | rentals_pending | film_id | |
customer | rental | customer_id | |
customer | inventory | rental | |
customer | films | inventory | |
customer | customer_payment_info | customer_id | |
customer | address | address_id |
- Public: reads
film, actor
tables, creates account incustomer
table, places order by creating row inrental_pending
table (before checkout, application requires to create an account) - Staff: reads
rental_pending
table, processes order by locating item frominventory
table, ships item to customer's address & creates record torental
table - Admin: creates, reads, updates, deletes
actor, film, customer, staff
tables