Open
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR integrates user authentication via Devise, switches the database to SQLite3 across environments, seeds a default user, and refactors blog post handling and layout to support authenticated actions and Tailwind CSS.
- Add Devise for user authentication and related views/routes
- Migrate database configuration/schema to SQLite3 and seed a default user
- Refactor
BlogPostsControllerto usebefore_actionand secure actions behind authentication
Reviewed Changes
Copilot reviewed 28 out of 34 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| db/seeds.rb | Add default user with hard-coded password |
| config/database.yml | Switch adapter from PostgreSQL to SQLite3 for all envs |
| app/models/user.rb | Update Devise modules (removed :registerable) |
| app/controllers/blog_posts_controller.rb | Refactor find and authentication logic; add destroy action |
Comments suppressed due to low confidence (3)
config/database.yml:2
- [nitpick] Using SQLite3 in production can lead to concurrency and performance bottlenecks. Consider switching to a more robust database (e.g., PostgreSQL) for production environments.
adapter: sqlite3
app/controllers/blog_posts_controller.rb:17
- The
@blog_postinstance is never initialized in thecreateaction. You’ve removed@blog_post = BlogPost.new(blog_post_params), so@blog_post.savewill raise a NoMethodError. Re-add initialization before saving.
if @blog_post.save
app/models/user.rb:4
- You removed
:registerablefrom the Devise modules but still render sign-up views and routes. Either re-enable:registerableor remove the sign-up UI to avoid routing errors.
devise :database_authenticatable,
Comment on lines
+13
to
+14
| password: "password", | ||
| password_confirmation: "password" |
There was a problem hiding this comment.
Seeding a user with a hard-coded password ("password") poses a security risk if this runs in non-local environments. Consider using environment variables or prompting the password only in development.
Suggested change
| password: "password", | |
| password_confirmation: "password" | |
| password: ENV.fetch("USER_PASSWORD") { Rails.env.development? ? "default_password" : raise("USER_PASSWORD environment variable is missing") }, | |
| password_confirmation: ENV.fetch("USER_PASSWORD") { Rails.env.development? ? "default_password" : raise("USER_PASSWORD environment variable is missing") } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.