Picgram: Team Project with Flatiron Alums — Week 1

Perezchristian
3 min readMay 5, 2021
Photo by William Krause on Unsplash

Some Flatiron School colleagues and myself decided to work on a group project in order to continue to flex our programming muscles! We decided to create a Instagram web application clone and add some features of d3.js, devise, Oauth and more in order to have more experience using these tools.

As this is my first big group project, I was looking forward to bouncing off ideas with focus driven people and I was glad that was the case. The first day we planned out the backend of our application by using a whiteboard to write down the model associations, our stretch goals, draft of our migrations, and a list of things we want the user to utilize. On day 2, we began to build out our backend application with ruby on rails and postgres for our database. After we added the bcyrpt gem for encryption and rack cors in order to handle cross domain AJAX calls. Next we installed the devise gem to handle authenticating the user that is signing up and logging in. With devise, we needed to run our devise create users migration and add devise to our user model. To handle our next layer of authentication, we installed the jwt gem in which it’s great and more secure to use because it creates and validates JWT tokens and if they match for a user then the user can successfully sign up and login. We need to generate jwt by adding the generate_jwt method and add registrations and sessions controllers to our routes files.

SCHEMA FILE

ActiveRecord::Schema.define(version: 2021_05_04_212552) do

# These are extensions that must be enabled in order to support this database
enable_extension “plpgsql”

create_table “comments”, force: :cascade do |t|
t.text “text”
t.integer “user_id”
t.integer “post_id”
t.datetime “created_at”, precision: 6, null: false
t.datetime “updated_at”, precision: 6, null: false
end

create_table “posts”, force: :cascade do |t|
t.string “image”
t.text “description”
t.integer “user_id”
t.datetime “created_at”, precision: 6, null: false
t.datetime “updated_at”, precision: 6, null: false
end

create_table “users”, force: :cascade do |t|
t.string “email”, default: “”, null: false
t.string “encrypted_password”, default: “”, null: false
t.bigint “friends_id”
t.bigint “followers_id”
t.bigint “following_id”
t.string “reset_password_token”
t.datetime “reset_password_sent_at”
t.datetime “remember_created_at”
t.datetime “created_at”, precision: 6, null: false
t.datetime “updated_at”, precision: 6, null: false
t.index [“email”], name: “index_users_on_email”, unique: true
t.index [“followers_id”], name: “index_users_on_followers_id”
t.index [“following_id”], name: “index_users_on_following_id”
t.index [“friends_id”], name: “index_users_on_friends_id”
t.index [“reset_password_token”], name: “index_users_on_reset_password_token”, unique: true
end

SEEDS FILE

User.destroy_all
Post.destroy_all
Comment.destroy_all

nerly = User.create(email: “nerly@me.com”, password: “123asd”)

jacob = User.create(email: “jacob@me.com”, password: “456fgh”)

christian = User.create(email: “christian@me.com”, password: “789jkl”)

post_one = Post.create(image: “http://somesite.com/123dicde", description: “this is me at the beach. yayyy”, user_id: nerly.id)

post_two = Post.create(image: “http://somesite.com/583rnie", description: “this is me at the mall. yayyy”, user_id: jacob.id)

post_three = Post.create(image: “http://somesite.com/429f9j", description: “this is me at the dealership. yayyy”, user_id: christian.id)

comment_one = Comment.create(text: “this is some text”, user_id: nerly.id, post_id: post_two.id)
comment_two = Comment.create(text: “this is some text”, user_id: jacob.id, post_id: post_three.id)
comment_three = Comment.create(text: “this is some text”, user_id: christian.id, post_id: post_one.id)

We ended off our week by adding our posts and comments controller and migrating our two migration files that detail our posts and comments. We also added our associations for posts and comments to the user and added User, post and comment data to the seeds file for testing. I have to say so far we were off to a strong start and we hope to make more progress for next week. Our Picgram repo link is below:

https://github.com/leplerjacob/picgram-backend/commit/5c8a42d0f609abcf32e3ed1c612c8de214a8f226

--

--

Perezchristian

Flatiron School Graduate with finance, budget, and tax experience.