Skip to content

Instantly share code, notes, and snippets.

@coaxial

coaxial/.rb Secret

Created December 21, 2022 10:01
Show Gist options
  • Save coaxial/7f1a49ceb99578454239b55fa0fa245c to your computer and use it in GitHub Desktop.
Save coaxial/7f1a49ceb99578454239b55fa0fa245c to your computer and use it in GitHub Desktop.
# controller
def create
@errors = []
params[:files].each |file|
document = Document.new(file:, ...)
if document.save
# handle success
else
# ...
@errors = document.errors
end
end
redirect_to_or_back root_path
end
# view
%h1= t('.title')
= form_with scope: documents, url: my_path do |f|
if @errors && @errors.any?
- @errors.full_messages.each do |message|
%p= message
%div.field
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment