Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mh starting on UI #91

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
646306a
install devise and add root
mauriushill Feb 28, 2024
da83c7b
generated users with devise
mauriushill Feb 28, 2024
2a6c84d
edited and migrated devise users.
mauriushill Feb 28, 2024
1caf265
generated photos.
mauriushill Feb 28, 2024
7ca395f
added colon to class name in the photo model.
mauriushill Feb 28, 2024
b5ccf6c
Generated comments.
mauriushill Feb 29, 2024
af75a3c
Generated follow request.
mauriushill Feb 29, 2024
c454348
Generated likes.
mauriushill Feb 29, 2024
74b6eb4
Added photo_count row to Users table.
mauriushill Feb 29, 2024
9864e0b
Added has_many method to comments.
mauriushill Feb 29, 2024
2b9deaa
Added 'has_many' methods to models with 'belong_to' statements.
mauriushill Feb 29, 2024
74dae38
Added methods to the user and photos table.
mauriushill Feb 29, 2024
ddadb56
Added more associate methods for User table.
mauriushill Feb 29, 2024
eabd776
Added validations to tables and added default to private.
mauriushill Feb 29, 2024
dbf4bbc
Added scope methods to Photo table.
mauriushill Feb 29, 2024
aa45237
Added enum method for follow request.
mauriushill Mar 4, 2024
7c48272
Created sample data & updated validations
mauriushill Mar 4, 2024
9b24931
Added info to dev.rake page for sample data.
mauriushill Mar 4, 2024
2e15d25
Added navbar and CDN assets.
mauriushill Mar 4, 2024
4576997
Styled the navbars drop down menu.
mauriushill Mar 5, 2024
cedf09f
updated navbar
mauriushill Mar 5, 2024
101a75a
Added if statements for user profile.
mauriushill Mar 5, 2024
241aaf0
Added better sample data.
mauriushill Mar 5, 2024
907ee53
Added alert and notice message flashes.
mauriushill Mar 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.2.1"

gem "devise"

gem "simple_form"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
Expand Down
14 changes: 14 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ GEM
tabulo
awesome_print (1.9.2)
base64 (0.1.1)
bcrypt (3.1.20)
better_errors (2.9.1)
coderay (>= 1.0.0)
erubi (>= 1.0.0)
Expand Down Expand Up @@ -109,6 +110,12 @@ GEM
irb (>= 1.5.0)
reline (>= 0.3.1)
debug_inspector (1.1.0)
devise (4.9.3)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
diff-lcs (1.5.0)
diffy (3.4.2)
domain_name (0.5.20190701)
Expand Down Expand Up @@ -215,6 +222,7 @@ GEM
faraday (>= 1, < 3)
sawyer (~> 0.9)
oj (3.13.23)
orm_adapter (0.5.0)
pg (1.4.6)
pry (0.14.2)
coderay (~> 1.1)
Expand Down Expand Up @@ -278,6 +286,9 @@ GEM
regexp_parser (2.8.2)
reline (0.3.9)
io-console (~> 0.5)
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
Expand Down Expand Up @@ -357,6 +368,8 @@ GEM
unf_ext
unf_ext (0.0.9.1)
unicode-display_width (2.4.2)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand Down Expand Up @@ -398,6 +411,7 @@ DEPENDENCIES
bootsnap
capybara
debug
devise
dotenv-rails
draft_matchers
faker
Expand Down
1 change: 1 addition & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
class ApplicationController < ActionController::Base
before_action :authenticate_user!
end
70 changes: 70 additions & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class CommentsController < ApplicationController
before_action :set_comment, only: %i[ show edit update destroy ]

# GET /comments or /comments.json
def index
@comments = Comment.all
end

# GET /comments/1 or /comments/1.json
def show
end

# GET /comments/new
def new
@comment = Comment.new
end

# GET /comments/1/edit
def edit
end

# POST /comments or /comments.json
def create
@comment = Comment.new(comment_params)

respond_to do |format|
if @comment.save
format.html { redirect_to comment_url(@comment), notice: "Comment was successfully created." }
format.json { render :show, status: :created, location: @comment }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @comment.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /comments/1 or /comments/1.json
def update
respond_to do |format|
if @comment.update(comment_params)
format.html { redirect_to comment_url(@comment), notice: "Comment was successfully updated." }
format.json { render :show, status: :ok, location: @comment }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @comment.errors, status: :unprocessable_entity }
end
end
end

# DELETE /comments/1 or /comments/1.json
def destroy
@comment.destroy

respond_to do |format|
format.html { redirect_to comments_url, notice: "Comment was successfully destroyed." }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_comment
@comment = Comment.find(params[:id])
end

# Only allow a list of trusted parameters through.
def comment_params
params.require(:comment).permit(:author_id, :photo_id, :body)
end
end
70 changes: 70 additions & 0 deletions app/controllers/follow_requests_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class FollowRequestsController < ApplicationController
before_action :set_follow_request, only: %i[ show edit update destroy ]

# GET /follow_requests or /follow_requests.json
def index
@follow_requests = FollowRequest.all
end

# GET /follow_requests/1 or /follow_requests/1.json
def show
end

# GET /follow_requests/new
def new
@follow_request = FollowRequest.new
end

# GET /follow_requests/1/edit
def edit
end

# POST /follow_requests or /follow_requests.json
def create
@follow_request = FollowRequest.new(follow_request_params)

respond_to do |format|
if @follow_request.save
format.html { redirect_to follow_request_url(@follow_request), notice: "Follow request was successfully created." }
format.json { render :show, status: :created, location: @follow_request }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @follow_request.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /follow_requests/1 or /follow_requests/1.json
def update
respond_to do |format|
if @follow_request.update(follow_request_params)
format.html { redirect_to follow_request_url(@follow_request), notice: "Follow request was successfully updated." }
format.json { render :show, status: :ok, location: @follow_request }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @follow_request.errors, status: :unprocessable_entity }
end
end
end

# DELETE /follow_requests/1 or /follow_requests/1.json
def destroy
@follow_request.destroy

respond_to do |format|
format.html { redirect_to follow_requests_url, notice: "Follow request was successfully destroyed." }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_follow_request
@follow_request = FollowRequest.find(params[:id])
end

# Only allow a list of trusted parameters through.
def follow_request_params
params.require(:follow_request).permit(:recipient_id, :sender_id, :status)
end
end
70 changes: 70 additions & 0 deletions app/controllers/likes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class LikesController < ApplicationController
before_action :set_like, only: %i[ show edit update destroy ]

# GET /likes or /likes.json
def index
@likes = Like.all
end

# GET /likes/1 or /likes/1.json
def show
end

# GET /likes/new
def new
@like = Like.new
end

# GET /likes/1/edit
def edit
end

# POST /likes or /likes.json
def create
@like = Like.new(like_params)

respond_to do |format|
if @like.save
format.html { redirect_to like_url(@like), notice: "Like was successfully created." }
format.json { render :show, status: :created, location: @like }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @like.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /likes/1 or /likes/1.json
def update
respond_to do |format|
if @like.update(like_params)
format.html { redirect_to like_url(@like), notice: "Like was successfully updated." }
format.json { render :show, status: :ok, location: @like }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @like.errors, status: :unprocessable_entity }
end
end
end

# DELETE /likes/1 or /likes/1.json
def destroy
@like.destroy

respond_to do |format|
format.html { redirect_to likes_url, notice: "Like was successfully destroyed." }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_like
@like = Like.find(params[:id])
end

# Only allow a list of trusted parameters through.
def like_params
params.require(:like).permit(:fan_id, :photo_id)
end
end
70 changes: 70 additions & 0 deletions app/controllers/photos_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
class PhotosController < ApplicationController
before_action :set_photo, only: %i[ show edit update destroy ]

# GET /photos or /photos.json
def index
@photos = Photo.all
end

# GET /photos/1 or /photos/1.json
def show
end

# GET /photos/new
def new
@photo = Photo.new
end

# GET /photos/1/edit
def edit
end

# POST /photos or /photos.json
def create
@photo = Photo.new(photo_params)

respond_to do |format|
if @photo.save
format.html { redirect_to photo_url(@photo), notice: "Photo was successfully created." }
format.json { render :show, status: :created, location: @photo }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @photo.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /photos/1 or /photos/1.json
def update
respond_to do |format|
if @photo.update(photo_params)
format.html { redirect_to photo_url(@photo), notice: "Photo was successfully updated." }
format.json { render :show, status: :ok, location: @photo }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @photo.errors, status: :unprocessable_entity }
end
end
end

# DELETE /photos/1 or /photos/1.json
def destroy
@photo.destroy

respond_to do |format|
format.html { redirect_to photos_url, notice: "Photo was successfully destroyed." }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_photo
@photo = Photo.find(params[:id])
end

# Only allow a list of trusted parameters through.
def photo_params
params.require(:photo).permit(:image, :comments_count, :likes_count, :caption, :owner_id)
end
end
26 changes: 26 additions & 0 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# == Schema Information
#
# Table name: comments
#
# id :bigint not null, primary key
# body :text not null
# created_at :datetime not null
# updated_at :datetime not null
# author_id :bigint not null
# photo_id :bigint not null
#
# Indexes
#
# index_comments_on_photo_id (photo_id)
#
# Foreign Keys
#
# fk_rails_... (author_id => users.id)
# fk_rails_... (photo_id => photos.id)
#
class Comment < ApplicationRecord
belongs_to :author, class_name: "User", counter_cache: true
belongs_to :photo

validates :body, presence: true
end
Loading