We use the dynamic_form gem in many places for reasons that we can't even remember -- so if we try to remove that gem, as we did in https://github.com/publiclab/plots2/pull/4575, tests fail. So let's fix this all and then circle back to that pull request to finish up!
Let's go through the uses of this gem everywhere we can find it and replace it with a more modern and standard form syntax! They look like this, using the error_messages property of the form_for block:
<%= form_for :revision, :as => :revision, :url => url, :html => {:class => "form"} do \|f\| %>
<% if f.error_messages != "" %>
<div class="alert alert-danger"><%= f.error_messages :header_message => "Your note couldn't be saved." %></div>
<% end %>
<% end %>
But they should look like this:
<% if @model.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@model.errors.count, "error") %> prohibited this model from being saved:</h2>
<ul>
<% @model.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
We can search to find where changes should be made, and the simpler of these may potentially be good first-timers-only issues, although if updating these cause tests to need updating too, that could be a potential barrier for a newcomer, so let's be sure to support people well in these!
Here are many instances that could be broken out into their own issues:
https://github.com/publiclab/plots2/search?q=error_messages&unscoped_q=error_messages
(we can keep adding links to instances in this list, as they are completed and checked off!)
I've made a first-timers-only issue from one of these! See how it looks to perform one of these updates by seeing this commit:
https://github.com/publiclab/plots2/commit/eada0c0970ebf1bcce1e6dcf384dc43813e9384a
Hey can I try working on this?
Hi @stacytonui -- sure, can you choose one from the checklist above, and open a pull request with that one file change, similar to https://github.com/publiclab/plots2/commit/eada0c0970ebf1bcce1e6dcf384dc43813e9384a ? And link to it from here? Thank you so much!
Okay let me work on the first one
@jywarren apologies for the first PR, my repo wasn't synced with the main one
@jywarren I'd like to work on the second one in plots2/app/views/users/_edit_form.html.erb if you can reserve it for me :) Will make a PR.
Can I give this a shot with plots2/app/views/map/edit.html.erb ?
Hi, @diorshelton - I'd love your help - but unfortunately the map/edit.html.erb file is the one I opened up a "first-timers-only" issue for and reserved for @asu1996 here - https://github.com/publiclab/plots2/issues/8546
Would you be willing to take on a different one from the list, or from the search results above? Your code looks great! Thank you for your understanding!
@noi5e I'll check out yours now, thank you too!
Hi @noi5e - are you working on this in https://github.com/publiclab/plots2/pull/8553 ? Need any help with the errors you're seeing? No worries, I'm here to support!
Hi, @jywarren can I work on question.html.erb?
@jywarren Yes, will reply to you in the PR, thank you!
Hi, @jywarren can I work on question.html.erb?
Yes, that would be great!!!
@jywarren - Looks like there are two instances in post.html.erb:
Happy to give these a shot if that's okay!
Most helpful comment
Okay let me work on the first one