Skip to content

Controller Validations Lab#7

Open
kyleghousel wants to merge 1 commit into
learn-co-curriculum:mainfrom
kyleghousel:sub
Open

Controller Validations Lab#7
kyleghousel wants to merge 1 commit into
learn-co-curriculum:mainfrom
kyleghousel:sub

Conversation

@kyleghousel
Copy link
Copy Markdown

@kyleghousel kyleghousel commented Aug 12, 2025

  • Check the validity of a model in a controller
  • Render a response with the error messages
  • Use HTTP status codes to provide additional context

Question for teacher: In practice, will we use the rescue_from approach? Or the custom inline approach like

author = Author.new(author_params)
if author.save
  render json: author, status: :created
else
  render json: { errors: author.errors.full_messages }, status: :unprocessable_entity
end

or...both

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