Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.
This repository was archived by the owner on Oct 28, 2024. It is now read-only.

add a docs example to show how to handle validation errors? #28

@jhackett1

Description

@jhackett1

when you file a request rather than do a normal save it doesn't seem like model validation errors display in the form.

i handled this with the code below, but i'm not sure it's the best solution or if it's handling all possible errors. would be good to address this in the docs!

    def create
        @service = current_user.organisation.services.build(service_params)
        if @service.valid?
            current_user.request_for_create(@service, reason: "something").save
            redirect_to organisations_path, notice: "Your service has been submitted for review. You'll be emailed when it's approved."
        else
            render "new"
        end
    end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions