Skip to content

Commit 769b1c0

Browse files
committed
fix validation errors
1 parent 77c19e2 commit 769b1c0

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

app/controllers/projects_controller.rb

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@ def create
2727
if @project.save
2828
redirect_to @project, notice: "Project created successfully!"
2929
else
30-
redirect_to new_project_path, inertia: {
31-
errors: @project.errors.to_hash(true),
32-
currency_options: Project.currency_options_for_select,
33-
user_preferred_currency: Current.user.preferred_currency
34-
}
30+
redirect_to new_project_path, inertia: { errors: @project.errors.as_json }
3531
end
3632
end
3733

@@ -46,9 +42,8 @@ def update
4642
if @project.update(project_params)
4743
redirect_to @project, notice: "Project updated successfully!"
4844
else
49-
redirect_to edit_project_path(@project), inertia: {
50-
errors: @project.errors.to_hash(true),
51-
currency_options: Project.currency_options_for_select
45+
redirect_to edit_project_path(@project), inertia: {
46+
errors: @project.errors.as_json
5247
}
5348
end
5449
end

app/frontend/pages/projects/new.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
3535
let errors = $page.props.errors || {};
3636
let isSubmitting = false;
37+
38+
// Reactively update errors when page props change
39+
$: errors = $page.props.errors || {};
3740
3841
function handleSubmit() {
3942
if (isSubmitting) return;

0 commit comments

Comments
 (0)