Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6720484
create new html file for comments
evans22j Jul 30, 2022
c30a087
Create likes_controller.rb
evans22j Jul 30, 2022
18c6f44
Create post_params private method in posts_controller.rb
evans22j Jul 30, 2022
63f0ce6
create new html file for comment
evans22j Jul 30, 2022
fc1a854
Create new html file for like and update show html file in posts
evans22j Jul 30, 2022
f08265a
Create new html file and update show html file in posts
evans22j Jul 30, 2022
afa087e
Update routes to include new and create actions
evans22j Jul 30, 2022
0e5d44b
resolve linter errors
evans22j Jul 30, 2022
3fbadb9
Update changes in readmile file
evans22j Jul 30, 2022
03bcc94
Add test for posts_index_spec.rb
evans22j Aug 1, 2022
e6863ce
Add test
evans22j Aug 1, 2022
f7abefc
fix n+1 and posts tests
evans22j Aug 1, 2022
a625610
n+1 and add tests
evans22j Aug 1, 2022
3226d35
fix linters
evans22j Aug 2, 2022
a14160a
add devise gem configuration
evans22j Aug 2, 2022
c4c3ab2
update styles
evans22j Aug 2, 2022
26aca8b
add user devise config in application controller
evans22j Aug 2, 2022
50e2873
create new html file in devise folder
evans22j Aug 2, 2022
78ea350
Update new.html.erb in registrations and sessions
evans22j Aug 2, 2022
79d7be3
Update application.erb in views/layouts
evans22j Aug 2, 2022
3ee66aa
Run rails db:migrate, and update index and shot html file in views/users
evans22j Aug 2, 2022
25cd143
add confirmable
evans22j Aug 2, 2022
5f420cf
add devise gem configuration
evans22j Aug 2, 2022
5c29be8
Run rails db:migrate, and update index and shot html file in views/users
evans22j Aug 2, 2022
52ffcd4
add user devise config in application controller
evans22j Aug 2, 2022
9e74141
resolve linter errors
evans22j Aug 2, 2022
3031726
Edit Readme
Aug 4, 2022
bf22ad6
Edit README.md
Aug 4, 2022
467477e
Add User Index Views
Aug 4, 2022
354efac
Reinstalled Devise
Aug 4, 2022
b0a8e6f
Edit User Model
Aug 4, 2022
1a5b56a
resolve changes in devise.rb
evans22j Aug 4, 2022
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
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

582 changes: 582 additions & 0 deletions .idea/blog-app.iml

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions .idea/codestyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ gem 'rails', '~> 7.0.3'
gem 'sprockets-rails'

# Use postgresql as the database for Active Record
gem 'pg'
gem 'pg', '~> 1.1'

# Use the Puma web server [https://github.com/puma/puma]
gem 'puma', '~> 5.0'
Expand Down Expand Up @@ -51,7 +51,6 @@ gem 'bootsnap', require: false
# gem "image_processing", "~> 1.2"

gem 'ffi'

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem 'rails-controller-testing'
Expand All @@ -60,6 +59,7 @@ end

group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem 'bullet'
gem 'web-console'

# Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler]
Expand All @@ -75,3 +75,5 @@ group :test do
gem 'selenium-webdriver'
gem 'webdrivers'
end

gem 'devise'
49 changes: 38 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ GEM
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.2)
bcrypt (3.1.18)
bindex (0.8.1)
bootsnap (1.13.0)
bootsnap (1.12.0)
msgpack (~> 1.2)
builder (3.2.4)
bullet (7.0.2)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
capybara (3.37.1)
addressable
matrix
Expand All @@ -85,15 +89,22 @@ GEM
childprocess (4.1.0)
concurrent-ruby (1.1.10)
crass (1.0.6)
devise (4.8.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
diff-lcs (1.5.0)
digest (3.1.0)
erubi (1.10.0)
ffi (1.15.5)
ffi (1.15.5-x64-mingw-ucrt)
globalid (1.0.0)
activesupport (>= 5.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
importmap-rails (1.1.5)
importmap-rails (1.1.3)
actionpack (>= 6.0.0)
railties (>= 6.0.0)
jbuilder (2.11.5)
Expand All @@ -110,7 +121,7 @@ GEM
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.16.2)
msgpack (1.5.4)
msgpack (1.5.3)
net-imap (0.2.3)
digest
net-protocol
Expand All @@ -126,12 +137,18 @@ GEM
net-protocol
timeout
nio4r (2.5.8)
nokogiri (1.13.8-x86_64-linux)
nokogiri (1.13.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.13.7-x64-mingw-ucrt)
racc (~> 1.4)
nokogiri (1.13.7-x86_64-linux)
racc (~> 1.4)
orm_adapter (0.5.0)
parallel (1.22.1)
parser (3.1.2.0)
ast (~> 2.4.1)
pg (1.4.2)
pg (1.4.1)
pg (1.4.1-x64-mingw-ucrt)
public_suffix (4.0.7)
puma (5.6.4)
nio4r (~> 2.0)
Expand Down Expand Up @@ -172,6 +189,9 @@ GEM
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.5.0)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.5)
rspec-core (3.11.0)
rspec-support (~> 3.11.0)
Expand All @@ -190,14 +210,14 @@ GEM
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.11.0)
rubocop (1.32.0)
rubocop (1.31.2)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.19.1, < 2.0)
rubocop-ast (>= 1.18.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.19.1)
Expand All @@ -216,20 +236,23 @@ GEM
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
stimulus-rails (1.1.0)
stimulus-rails (1.0.4)
railties (>= 6.0.0)
strscan (3.0.4)
strscan (3.0.3)
thor (1.2.1)
timeout (0.3.0)
turbo-rails (1.1.1)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
railties (>= 6.0.0)
tzinfo (2.0.5)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2022.1)
tzinfo (>= 1.0.0)
unicode-display_width (2.2.0)
uniform_notifier (1.16.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.0)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
Expand All @@ -248,15 +271,19 @@ GEM
zeitwerk (2.6.0)

PLATFORMS
arm64-darwin-21
x64-mingw-ucrt
x86_64-linux

DEPENDENCIES
bootsnap
bullet
capybara
devise
ffi
importmap-rails
jbuilder
pg
pg (~> 1.1)
puma (~> 5.0)
rails (~> 7.0.3)
rails-controller-testing
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ This project is build with:
- Twitter: [@Evans_22J](https://twitter.com/Evans_22J)
- LinkedIn: [@Evans Sitibekiso](https://www.linkedin.com/in/evans-sitibekiso/)

👤 **Edward Odhiambo**

- GitHub: [@whit3d](https://github.com/white3d)
- Twitter: [@odhiambo_ed](https://twitter.com/odhiambo_ed)
- LinkedIn: [Edward Odhiambo](https://www.linkedin.com/in/edward-odhiambo-6a462a21b/)

## 🤝 Contributor


Expand All @@ -192,4 +198,4 @@ Give a ⭐️ if you like this project!

## 📝 License

This project is [MIT](./MIT.md) licensed.
This project is [MIT](https://github.com/microverseinc/readme-template/blob/master/MIT.md) licensed.
Binary file added app/assets/images/margaret.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions app/assets/stylesheets/user_style.css
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ a {
}

.button-user {
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}

.text-button {
Expand All @@ -162,14 +164,15 @@ a {
background-color: #2f4858;
border: none;
color: white;
padding: 10px 20px;
padding: 15px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
margin: 10px;
cursor: pointer;
border-radius: 4px;
width: 150px;
}

.post-info,
Expand Down
10 changes: 8 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
class ApplicationController < ActionController::Base
def current_user
User.first
before_action :authenticate_user!
protect_from_forgery with: :exception
before_action :update_allowed_parameters, if: :devise_controller?

def update_allowed_parameters
devise_parameter_sanitizer.permit(:sign_up) do |field|
field.permit(:name, :photo, :bio, :posts_counter, :email, :password, :password_confirmation)
end
end
end
29 changes: 29 additions & 0 deletions app/controllers/comments_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class CommentsController < ApplicationController
def new
@comment = Comment.new
@user = current_user
end

def create
@post = Post.find(params[:post_id] || params[:id])
@comment = Comment.new(comment_params)
@comment.author_id = current_user.id
@comment.post = @post

respond_to do |format|
if @comment.save!
format.html do
redirect_to user_post_url(current_user, @post), notice: 'Comment was successfully created.'
end
else
format.html { render :new, status: :unprocessable_entity }
end
end
end

private

def comment_params
params.require(:comment).permit(:text)
end
end
20 changes: 20 additions & 0 deletions app/controllers/likes_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class LikesController < ApplicationController
def new
@like = Like.new
@user = current_user
end

def create
@post = Post.find(params[:post_id] || params[:id])
@like = Like.new(post_id: @post.id, author_id: current_user.id)
@like.author_id = current_user.id

respond_to do |format|
if @like.save
format.html { redirect_to user_post_url(current_user, @post), notice: 'Like was successfully created.' }
else
format.html { render :new, status: :unprocessable_entity }
end
end
end
end
Loading