Rails, using ActiveAdmin, trying to warn users that some data might be missing.
--Not by using model validations--
I just need a modal that makes user acknowledge (by clicking 'OK' or 'Cancel') that some fields are missing, but can still submit the form. I have similar boiler-plate working code elsewhere that looks something like:
text_node link_to "Delete", admin_gath_line_app_permit_path(permit), :method => :delete, :data => { :confirm => "Are you sure?" }
I'm trying to bring that same :confirm modal magic to my 'def create' with this non-working bit of code:
def create
create! do |format|
if resource.errors.present?
return render :edit
else
if !resource.GL_Permit.present?
format.html { redirect_to admin_gath_lines_path(), :data => {:confirm = "what about the GL Permit?" }}
else
resource.reload
format.html { redirect_to admin_gath_lines_path() }
end
end
end
end
CodePudding user response:
Could try something like:
def create
create! do |format|
if resource.errors.present?
return render :edit
else
if !resource.GL_Permit.present?
format.html { redirect_to admin_gath_lines_path(), alert: "ALERT, WARNING"}
else
resource.reload
format.html { redirect_to admin_gath_lines_path() }
end
end
end end