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

Week 4 Weekend challenge #1721

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open

Week 4 Weekend challenge #1721

wants to merge 36 commits into from

Conversation

kerisic
Copy link

@kerisic kerisic commented Feb 28, 2021

User can sign up, log in, log out. Posting a peep is only possible when authenticated as a user. Most user stories completed except for the last one (sending an email when tagged in a 'peep'). Also didn't implement replies functionality. Minimal css was also used. Probably could have done better in making the controller neater and need to make unit tests more isolated as some (Peep class) were dependent on the User class.

Comment on lines +12 to +16
get '/peeps' do
@user = User.find(session[:user_id])
@peeps = Peep.all
erb :'peeps/index'
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your route has been kept skinny, very clean and easy to follow the flow of requests. One question on RESTful route, could you have used parameters in some of the routes?

Comment on lines +1 to +14
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
<<: *default
database: peep_manager

production:
<<: *default
database: peepmanager
username: myapp
password: <%= ENV['MYAPP_DATABASE_PASSWORD'] %>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one! you really took the time to work on the travis file!

Comment on lines +1 to +11
require 'pg'

class DatabaseConnection
def self.setup(dbname)
@connection = PG.connect(dbname: dbname)
end

def self.query(sql)
@connection.exec(sql)
end
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great user of SRP, having a DatabaseConnection class makes the files cleaner - 100%!

Comment on lines +4 to +14
class Peep
def self.create(content:, user:)
time = Time.now.strftime('%T')
result = DatabaseConnection.query("INSERT INTO peeps (content, user_id, time_created) VALUES ($$#{content}$$, #{user.id}, '#{time}') RETURNING id, content, time_created;")
Peep.new(
id: result[0]['id'],
content: result[0]['content'],
time: result[0]['time_created'],
user: user
)
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having the database class allows you to keep your other classes net

Comment on lines +4 to +6
class User
def self.create(email:, password:, name:, username:)
encrypted_password = BCrypt::Password.create(password)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great use of bcrytp

@sandyMax974
Copy link

Great use of SRP, encapsulation, MVC and keeping a skinny controller. Very impressive used of the new technologies like Travis or the BCrypt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants