Skip to content

Add Validations and Error Handling#9

Open
mclancy96 wants to merge 3 commits into
learn-co-curriculum:mainfrom
mclancy96:new-branch
Open

Add Validations and Error Handling#9
mclancy96 wants to merge 3 commits into
learn-co-curriculum:mainfrom
mclancy96:new-branch

Conversation

@mclancy96
Copy link
Copy Markdown

This pull request introduces several improvements for Ruby 3.3+ compatibility, adds model validations, and enhances error handling in controllers. The most important changes are grouped below by theme.

Ruby 3.3+ Compatibility and Dependency Updates:

  • Added gems (bigdecimal, fiddle, logger, mutex_m, ostruct, nio4r) to the Gemfile to prepare for Ruby 3.3/3.4/3.5 stdlib removals and updated sqlite3 to a compatible version. Also updated platform array syntax for consistency. [1] [2]
  • Updated config/boot.rb to explicitly require logger for ActiveSupport compatibility with Ruby 3.3+.
  • Modified config/database.yml to remove YAML aliases for compatibility with Ruby 3.3+ and Psych changes.

Model Validations:

  • Added validations in Author for presence and minimum length of name, and uniqueness of email.
  • Added validations in Post for presence of title, inclusion of category in allowed values, and minimum length for content.

Controller Error Handling Improvements:

  • Updated AuthorsController and PostsController to use create!/update! and rescue ActiveRecord::RecordInvalid, returning structured error responses for validation failures. [1] [2] [3]

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