Home - NischithaCNagaraju/PhotoSite GitHub Wiki

Welcome to the PhotoSite wiki! CS-651 –WEBSYSTEMS - PROJECT R1

Simple PhotoSite in Ruby on Rails using SQLite database Nischitha Chottanahalli Nagaraju (zj2583)

Youtube link : https://youtu.be/VBjClYs5EHc

Objective: The objective of this project is to get hands on experience in Ruby on Rails application using SQLite Database by creating a PhotoSite application. Aim: The aim of the project is to design MVC (model-view-controller) based photo-sharing website using Ruby-on-Rails with SQLite database. It is a photo sharing web application which displays all users information and their photos with associated comments by other users. Design The design of this project starts with three models

  1. User
  2. Photo
  3. Comment With these model , migration files are updated to create tables in database, with given structure of database to use in this project Controller logic is created to fetch the data from database. Following views are created to browse given requirements on web browser.
  4. /user/index – Displays all users
  5. /user/photo/:id – Display all photos of a user and respected comments.

Status: Running  Displayed list of all 6 users from given database  Displayed all photos of user along with date of creation  Displayed all comments and updated date of comment  Each comment is linked to photo page of the commented user

  Item 1: Use migrations to create the database

  1. Create User model
  2. Create Photo model
  3. Create Comment model RubyMine: Tools-> Run Rails Generator -> model

Below screenshot shows how to create model and on the left side we can see creation of model files of user, photo and comment and also its corresponding migration file.

![model] (https://user-images.githubusercontent.com/61173798/74882873-b93e0900-5324-11ea-8344-4a227a3ea25f.PNG)

  1. Create a data migration file to Pre_Load Data COMMAND LINE: rails generate migration load_data

RubyMine IDE: Tools-> Run Rails Generator -> migration (then give the name load_data) As shown below

![migration] (https://user-images.githubusercontent.com/61173798/74883006-e8ed1100-5324-11ea-8b03-e602c9e10534.PNG)

  1. Run all the migrations you setup COMMAND LINE: rake db:migrate

RubyMine IDE: Tools->Run Rake Task -> db:migrate

This will run all of your migrations, creating the database schema and loading the initial data

![raketest] (https://user-images.githubusercontent.com/61173798/74883030-f6a29680-5324-11ea-9c45-6aad18be4999.PNG)

  1. RUN RUBYMINE's database tool too see you have created the tables

Click on database and select import from source selecting the local SQLite

![image] (https://user-images.githubusercontent.com/61173798/74883935-e7244d00-5326-11ea-902d-dc4e5b6a881f.png)

So this displays schema as shown below

Schema

![Schema] (https://user-images.githubusercontent.com/61173798/74883989-00c59480-5327-11ea-9234-796ea3fa9090.PNG)

Item 2 : Create the application using controllers and views that implement two URL’s The first URL is /users/index –

![image] (https://user-images.githubusercontent.com/61173798/74884083-37031400-5327-11ea-98b3-9f66dc9f6101.png)

The second URL is /photos/index/id

![url2] (https://user-images.githubusercontent.com/61173798/74884234-88ab9e80-5327-11ea-879c-62f51c15332b.PNG)

When you click on the creator of comment it should go to that person’s page: ![url2] (https://user-images.githubusercontent.com/61173798/74884292-b1339880-5327-11ea-8bdb-0aae47931c37.PNG)

So here if we click on paris it should go to paris page as shown below. ![Clickto] (https://user-images.githubusercontent.com/61173798/74884340-cc060d00-5327-11ea-8b0d-6e9db55673ed.PNG)