Migrate deprecated form_tag and form_for to form_with

See next commit for note on running view style checks.
This commit is contained in:
Abdullah Samman 2018-12-09 17:51:30 +02:00 committed by Peter Bhat Harkins
parent 8f46f991f3
commit 089f3475ba
32 changed files with 153 additions and 116 deletions

View File

@ -4,6 +4,7 @@
# Project setup:
require: ./extras/prohibit_safe_navigation
require: ./extras/prohibit_form_for_and_form_tag
Rails:
Enabled: true
AllCops:

9
.ruumba.yml Normal file
View File

@ -0,0 +1,9 @@
require: ./extras/prohibit_form_for_and_form_tag
AllCops:
DisabledByDefault: true
Style/DisallowFormForandFormTag:
Enabled: true
Include:
- '**/*.erb'

View File

@ -37,6 +37,8 @@ gem "oauth" # for twitter-posting bot
gem "mail" # for parsing incoming mail
gem "sitemap_generator" # for better search engine indexing
gem "ruumba"
group :test, :development do
gem 'bullet'
gem 'capybara'

View File

@ -196,6 +196,8 @@ GEM
i18n
ruby-progressbar (1.10.0)
ruby_dep (1.5.0)
ruumba (0.1.8)
rubocop
scenic (1.4.1)
activerecord (>= 4.0.0)
railties (>= 4.0.0)
@ -261,6 +263,7 @@ DEPENDENCIES
rspec-rails
rubocop
rubocop-rspec
ruumba
scenic
scenic-mysql_adapter
sitemap_generator

View File

@ -1,20 +1,19 @@
<div class="comment comment_form_container"
data-shortid="<%= comment.short_id if comment.persisted? %>">
<%= form_for comment,
:html => { :id => "edit_comment_#{comment.short_id}" } do |f| %>
<%= form_with url: comment, :id => "edit_comment_#{comment.short_id}" do |f| %>
<% if comment.errors.any? %>
<%= errors_for comment %>
<% end %>
<%= hidden_field_tag "story_id", comment.story.short_id %>
<%= f.hidden_field "story_id", :value => comment.story.short_id %>
<% if comment.parent_comment %>
<%= hidden_field_tag "parent_comment_short_id",
<%= f.hidden_field "parent_comment_short_id",
comment.parent_comment.short_id %>
<% end %>
<div style="width: 100%;">
<%= text_area_tag "comment", comment.comment, :rows => 5,
<%= f.text_area "comment", :body => comment.comment, :rows => 5,
:disabled => !@user,
:placeholder => (@user ? "" : "You must be logged in to leave a comment.")
%>
@ -32,21 +31,21 @@ data-shortid="<%= comment.short_id if comment.persisted? %>">
</div>
<% end %>
<%= submit_tag "#{comment.new_record?? "Post" : "Update"}",
<%= f.submit "#{comment.new_record?? "Post" : "Update"}",
:class => "comment-post", :disabled => !@user %>
&nbsp;
<%= button_tag "Preview", :class => "comment-preview",
<%= f.button "Preview", :class => "comment-preview",
:type => "button", :disabled => !@user %>
<% if comment.persisted? || comment.parent_comment_id %>
&nbsp;
<%= button_tag "Cancel", :class => "comment-cancel",
<%= f.button "Cancel", :class => "comment-cancel",
:type => "button" %>
<% end %>
<% if @user && @user.wearable_hats.any? %>
<div style="display: inline-block; margin-left: 1em;">
Put on hat:
<%= select_tag "hat_id",
<%= f.select "hat_id",
options_from_collection_for_select(@user.wearable_hats, "id", "hat",
comment.hat_id), :include_blank => true %>
</div>

View File

@ -16,7 +16,7 @@
</p>
<% end %>
<%= form_tag "/filters", :method => :post do %>
<%= form_with url: "/filters", :method => :post do |f| %>
<table class="data zebra" cellspacing=0 width="75%">
<tr>
<th width="7%">Hide</th>
@ -41,7 +41,7 @@
<% end %>
</table>
<p>
<%= submit_tag "Save Filters" %>
<%= f.submit "Save Filters" %>
</p>
<% end %>
</div>

View File

@ -36,7 +36,7 @@
verification of project association.
</p>
<%= form_for @hat_request, :url => create_hat_request_path do |f| %>
<%= form_with model: @hat_request, :url => create_hat_request_path do |f| %>
<p>
<%= f.label :hat, "Hat:" %>
<%= f.text_field :hat, :size => 20,

View File

@ -11,7 +11,7 @@
<hr>
<% end %>
<%= form_for hr, :url => approve_hat_request_url(:id => hr),
<%= form_with model: hr, :url => approve_hat_request_url(:id => hr),
:method => :post do |f| %>
<p>
<div class="boxline">
@ -42,20 +42,20 @@
</div>
<p style="clear: both;">
<%= submit_tag "Approve Hat Request" %>
<%= f.submit "Approve Hat Request" %>
</p>
<% end %>
<p>
or
</p>
<%= form_for hr, :url => reject_hat_request_url(:id => hr),
<%= form_with model: hr, :url => reject_hat_request_url(:id => hr),
:method => :post do |f| %>
<div class="boxline">
<%= f.label :link, "Reason:", :class => "required" %>
<%= f.text_area :rejection_comment, :rows => 4 %>
</div>
<p>
<%= submit_tag "Reject Hat Request" %>
<%= f.submit "Reject Hat Request" %>
</p>
<% end %>
<% end %>

View File

@ -16,7 +16,7 @@
shown to any other users (except moderators).
</p>
<%= form_for @invitation_request,
<%= form_with model: @invitation_request,
:url => create_invitation_by_request_path do |f| %>
<p>
<%= f.label :name, "Name (not username):" %>
@ -36,7 +36,7 @@
</p>
<p>
<%= submit_tag "Request Invitation" %>
<%= f.submit "Request Invitation" %>
</p>
<% end %>
</div>

View File

@ -26,14 +26,14 @@
<em><%= ir.email %></em>
<% end %></td>
<td><%= raw ir.markeddown_memo %></td>
<td><%= form_tag send_invitation_for_request_path do %>
<%= hidden_field_tag "code", ir.code %>
<%= submit_tag "Send Invitation", :data => { :confirm => "Are " <<
<td><%= form_with url: send_invitation_for_request_path do |f| %>
<%= f.hidden_field "code", :value => ir.code %>
<%= f.submit "Send Invitation", :data => { :confirm => "Are " <<
"you sure you want to invite this person and remove this request?" } %>
<% end %></td>
<td><%= form_tag delete_invitation_request_path do %>
<%= hidden_field_tag "code", ir.code %>
<%= submit_tag "Delete", :data => { :confirm => "Are you sure " <<
<td><%= form_with url: delete_invitation_request_path do |f| %>
<%= f.hidden_field "code", :value => ir.code %>
<%= f.submit "Delete", :data => { :confirm => "Are you sure " <<
"you want to delete this request?" } %>
<% end %>
</tr>

View File

@ -8,13 +8,13 @@
below and instructions will be e-mailed to you.
</p>
<%= form_tag reset_password_path do %>
<%= label_tag :email, "E-mail or Username:" %>
<%= text_field_tag :email, "", :size => 30 %>
<%= form_with url: reset_password_path do |f| %>
<%= f.label :email, "E-mail or Username:" %>
<%= f.text_field :email, :size => 30 %>
<br />
<p>
<%= submit_tag "Reset Password" %>
<%= f.submit "Reset Password" %>
</p>
<% end %>
</div>

View File

@ -8,19 +8,19 @@
The site is currently in read-only mode for maintenance.
</p>
<% else %>
<%= form_tag login_path do %>
<%= form_with url: login_path do |form| %>
<p>
<%= label_tag :email, "E-mail or Username:" %>
<%= text_field_tag :email, "", :size => 30, :autofocus => "autofocus" %>
<%= form.label :email, "E-mail or Username:" %>
<%= form.text_field :email, :size => 30, :autofocus => "autofocus" %>
<br />
<%= label_tag :password, "Password:" %>
<%= password_field_tag :password, "", :size => 30 %>
<%= form.label :password, "Password:" %>
<%= form.password_field :password, :size => 30 %>
<br />
</p>
<p>
<%= submit_tag "Login" %>
<%= form.submit "Login" %>
</p>
<p>

View File

@ -3,26 +3,26 @@
Set New Password
</div>
<%= form_tag set_new_password_path, { :autocomplete => "off" } do %>
<%= form_with url: set_new_password_path, :autocomplete => "off" do |f| %>
<%= error_messages_for(@reset_user) %>
<%= hidden_field_tag "token", params[:token] %>
<%= f.hidden_field "token", :value => params[:token] %>
<p>
<%= label_tag :username, "Username:" %>
<%= f.label :username, "Username:" %>
<%= @reset_user.username %>
<br />
<%= label_tag :password, "New Password:" %>
<%= password_field_tag :password, "", :size => 30 %>
<%= f.label :password, "New Password:" %>
<%= f.password_field :password, :size => 30 %>
<br />
<%= label_tag :password_confirmation, "(Again):" %>
<%= password_field_tag :password_confirmation, "", :size => 30 %>
<%= f.label :password_confirmation, "(Again):" %>
<%= f.password_field :password_confirmation, :size => 30 %>
<br />
<p>
<%= submit_tag "Set New Password" %>
<%= f.submit "Set New Password" %>
</p>
<% end %>
</div>

View File

@ -3,20 +3,20 @@
Login - Two Factor Authentication
</div>
<%= form_tag twofa_login_url do %>
<%= form_with url: twofa_login_url do |f| %>
<p>
Enter the current TOTP code from your TOTP application:
</p>
<p>
<%= label_tag :totp_code, "TOTP Code:" %>
<%= number_field_tag :totp_code, "", :size => 10, :autocomplete => "off",
<%= f.label :totp_code, "TOTP Code:" %>
<%= f.number_field :totp_code, :size => 10, :autocomplete => "off",
:autofocus => true, :class => "totp_code" %>
<br />
</p>
<p>
<%= submit_tag "Login" %>
<%= f.submit "Login" %>
</p>
<% end %>
</div>

View File

@ -1,8 +1,8 @@
<%= form_for new_message, :method => :post do |f| %>
<%= form_with model: @new_message, url: new_message, :method => :post do |f| %>
<%= error_messages_for @new_message %>
<% if replying %>
<%= f.hidden_field :recipient_username %>
<%= f.hidden_field :recipient_username %>
<% else %>
<div class="boxline">
<%= f.label :recipient_username, "To:", :class => "required" %>
@ -38,6 +38,6 @@
<div class="boxline">
<p></p>
<%= submit_tag replying ? "Reply" : "Send Message" %>
<%= f.submit replying ? "Reply" : "Send Message" %>
</div>
<% end %>

View File

@ -23,7 +23,7 @@
</div>
<% if @messages.any? %>
<%= form_tag batch_delete_messages_path do %>
<%= form_with url: batch_delete_messages_path do |f| %>
<table class="data zebra" width="100%" cellspacing=0>
<tr>
<th width="3%"><%= check_box_tag "delete_all",
@ -58,7 +58,7 @@
<% end %>
</table>
<p>
<%= submit_tag "Delete Selected" %>
<%= f.submit "Delete Selected" %>
</p>
<% end %>
<% else %>

View File

@ -33,21 +33,21 @@
<div class="boxline">
<div style="float: left;">
<%= form_tag message_path(@message.short_id), :method => :delete do %>
<%= submit_tag "Delete Message" %>
<%= form_with url: message_path(@message.short_id), :method => :delete do |f| %>
<%= f.submit "Delete Message" %>
<% end %>
</div>
<div style="float: left; padding-left: 1em;">
<%= form_tag message_keep_as_new_path(@message.short_id), :method => :post do %>
<%= submit_tag "Keep As New" %>
<%= form_with url: message_keep_as_new_path(@message.short_id), :method => :post do |f| %>
<%= f.submit "Keep As New" %>
<% end %>
</div>
<% if @user.is_moderator? %>
<div style="float: left; padding-left: 1em;">
<%= form_tag message_mod_note_path(@message.short_id), :method => :post do %>
<%= submit_tag "ModNote" %>
<%= form_with url: message_mod_note_path(@message.short_id), :method => :post do |f| %>
<%= f.submit "ModNote" %>
<% end %>
</div>
<% end %>

View File

@ -1,10 +1,10 @@
<%= render partial: 'mod/nav' %>
<%= form_tag mod_notes_path, method: :get do |f| %>
<%= form_with url: mod_notes_path, method: :get do |f| %>
<div class="boxline">
<label class="normal" for="username">Username:</label>
<input type="text" name="username" value="<%= @username %>">
<%= submit_tag 'Filter' %>
<%= f.submit 'Filter' %>
</div>
<% end %>

View File

@ -3,9 +3,9 @@
Moderation Log
</div>
<%= form_tag(moderations_path, :method => :get) do |f| %>
<%= form_with url: moderations_path, :method => :get do |f| %>
<label class="normal" for="moderator">Moderator:</label>
<%= select_tag 'moderator', options_for_select(@moderators, @moderator) %>
<%= f.select 'moderator', options_for_select(@moderators, @moderator) %>
<% @what.each do |type, checked| %>
<%= check_box_tag "what[#{type}]", type, checked %>
<label class="normal" for="what_<%= type %>"><%= type.to_s.titlecase %></label>

View File

@ -3,9 +3,9 @@
Search
</div>
<%= form_tag "/search", :method => :get do %>
<%= form_with url: "/search", :method => :get do |f| %>
<div class="boxline">
<%= text_field_tag "q", @search.q, { :size => 40 }.
<%= f.text_field "q", { :value => @search.q, :size => 40 }.
merge(@search.q.present? ? {} : { :autofocus => "autofocus" }) %>
<input type="submit" value="Search">
</div>
@ -13,29 +13,29 @@
<div class="boxline">
<label class="required">Search:</label>
<%= radio_button_tag "what", "stories", @search.what == "stories" %>
<%= f.radio_button "what", "stories", :checked => @search.what == "stories" %>
<label for="what_stories" class="normal">Stories</label>
&nbsp;
<%= radio_button_tag "what", "comments", @search.what == "comments" %>
<%= f.radio_button "what", "comments", :checked => @search.what == "comments" %>
<label for="what_comments" class="normal">Comments</label>
<br>
<label class="required">Order By:</label>
<%= radio_button_tag "order", "relevance", @search.order == "relevance" %>
<%= f.radio_button "order", "relevance", :checked => @search.order == "relevance" %>
<label for="order_relevance" class="normal">Relevance</label>
&nbsp;
<%= radio_button_tag "order", "newest", @search.order == "newest" %>
<%= f.radio_button "order", "newest", :checked => @search.order == "newest" %>
<label for="order_newest" class="normal">Newest</label>
&nbsp;
<%= radio_button_tag "order", "points", @search.order == "points" %>
<%= f.radio_button "order", "points", :checked => @search.order == "points" %>
<label for="order_points" class="normal">Points</label>
</div>
<% end %>

View File

@ -10,8 +10,8 @@
Account Settings (<a href="/u/<%= @user.username %>">View Profile</a>)
</div>
<%= form_for @edit_user, :url => settings_path, :method => :post,
:html => { :id => "edit_user" } do |f| %>
<%= form_with :model => @edit_user, :url => settings_path, :method => :post,
:id => "edit_user" do |f| %>
<%= error_messages_for f.object %>
<div class="boxline">
@ -23,9 +23,9 @@
</div>
<div class="boxline">
<%= label_tag :current_password, "Current Password:",
<%= f.label :current_password, "Current Password:",
:class => "required" %>
<%= password_field_tag :current_password, nil, :size => 40 %>
<%= f.password_field :current_password, :name => "current_password", :size => 30 %>
</div>
<div class="boxline">
@ -74,7 +74,7 @@
</div>
<div class="boxline">
<%= label_tag :gravatar,
<%= f.label :gravatar,
raw("<a href=\"https://gravatar.com/\">Gravatar</a>:"),
:class => "required" %>
<span>
@ -86,7 +86,7 @@
<% if Pushover.enabled? %>
<div class="boxline">
<%= label_tag :pushover_user_key,
<%= f.label :pushover_user_key,
raw("<a href=\"https://pushover.net/\">Pushover</a>:"),
:class => "required" %>
<span>
@ -104,7 +104,7 @@
<% if Github.enabled? %>
<div class="boxline">
<span>
<%= label_tag :github_username,
<%= f.label :github_username,
raw("<a href=\"https://github.com/\">GitHub</a>:"),
:class => "required" %>
<% if @edit_user.github_username.present? %>
@ -122,7 +122,7 @@
<% if Twitter.enabled? %>
<div class="boxline">
<%= label_tag :twitter_username,
<%= f.label :twitter_username,
raw("<a href=\"https://twitter.com/\">Twitter</a>:"),
:class => "required" %>
<span>
@ -301,8 +301,8 @@
<br>
<div class="deletion">
<%= form_for @edit_user, :url => delete_account_path, :method => :post,
:html => { :id => "delete_user" } do |f| %>
<%= form_with :model => @edit_user, :url => delete_account_path, :method => :post,
:id => "delete_user" do |f| %>
<div class="legend">
Delete Account
</div>
@ -329,10 +329,10 @@
</div>
<div class="boxline">
<%= f.label :i_am_sure, "I am sure:", :class => "required" %>
<%= check_box_tag :i_am_sure %>
<%= f.check_box :i_am_sure %>
<br />
<%= f.label :disown, "Disown Comments:" %>
<%= check_box_tag :disown %> (optional)
<%= f.check_box :disown %> (optional)
</div>
<%= f.submit "Yes, Delete My Account", :class => "deletion" %>
<% end %>

View File

@ -6,7 +6,7 @@
<%= @title %>
</div>
<%= form_for @user, :url => twofa_auth_url, :method => :post do |f| %>
<%= form_with :model => @user, :url => twofa_auth_url, :method => :post do |f| %>
<p>
<% if @user.has_2fa? %>
To turn off two-factor authentication for your account, enter your
@ -24,9 +24,9 @@
<p>
<% if @user.has_2fa? %>
<%= submit_tag "Disable Two-Factor Authentication" %>
<%= f.submit "Disable Two-Factor Authentication" %>
<% else %>
<%= submit_tag "Continue" %>
<%= f.submit "Continue" %>
<% end %>
<% end %>
</div>

View File

@ -6,19 +6,19 @@
<%= @title %>
</div>
<%= form_tag twofa_update_url do %>
<%= form_with url: twofa_update_url do |f| %>
<p>
To enable Two-Factor Authentication on your account using your new TOTP
secret, enter the six-digit code from your TOTP application:
</p>
<div class="boxline">
<%= label_tag :totp_code, "TOTP Code:", :class => "required" %>
<%= number_field_tag :totp_code, "", :size => 10, :autocomplete => "off",
<%= f.label :totp_code, "TOTP Code:", :class => "required" %>
<%= f.number_field :totp_code, :size => 10, :autocomplete => "off",
:autofocus => true, :class => "totp_code" %>
</div>
<p>
<%= submit_tag "Verify and Enable" %>
<%= f.submit "Verify and Enable" %>
<% end %>
</div>

View File

@ -3,7 +3,7 @@
Create an Account
</div>
<%= form_for @new_user, { :url => signup_path } do |f| %>
<%= form_with model: @new_user, :url => signup_path do |f| %>
<p>
To create a new account, enter your e-mail address and a password.
Your e-mail address will never be shown to users and will only be used
@ -14,7 +14,7 @@
<%= error_messages_for(@new_user) %>
<% if not Rails.application.open_signups? %>
<%= hidden_field_tag "invitation_code", @invitation.code %>
<%= f.hidden_field "invitation_code", :value => @invitation.code %>
<p>
<%= f.label :invitation, "Invited By:", :class => "required" %>
<span class="d">
@ -75,7 +75,7 @@
</div>
<p>
<%= submit_tag "Signup" %>
<%= f.submit "Signup" %>
</p>
<% end %>
</div>

View File

@ -17,7 +17,7 @@
<% if defined?(f) %>
<%= f.hidden_field :seen_previous %>
<% else %>
<%= form_for story do |f| %>
<%= form_with model: story do |f| %>
<%= f.hidden_field :seen_previous %>
<% end %>
<% end %>

View File

@ -3,8 +3,8 @@
Edit Story
</div>
<%= form_for @story, :url => story_path(@story.short_id),
:method => :put, :html => { :id => "edit_story" } do |f| %>
<%= form_with model: @story, :url => story_path(@story.short_id),
:method => :put, :id => "edit_story" do |f| %>
<%= render :partial => "stories/form", :locals => { :story => @story,
:f => f } %>
@ -43,7 +43,7 @@
Markdown formatting available
</div>
<%= submit_tag "Save" %>
<%= f.submit "Save" %>
<% if @story.is_gone? && @story.is_undeletable_by_user?(@user) %>
&nbsp; | &nbsp;

View File

@ -4,7 +4,7 @@
</div>
<div id="story_holder">
<%= form_for @story do |f| %>
<%= form_with model: @story do |f| %>
<%= render :partial => "stories/form", :locals => { :story => @story, :f => f } %>
<p></p>
@ -15,7 +15,7 @@
Markdown formatting available
</div>
<%= submit_tag "Submit" %>
<%= f.submit "Submit" %>
&nbsp;
<button type="button" class="story-preview">Preview</button>

View File

@ -3,7 +3,7 @@
Suggest Story Changes
</div>
<%= form_for @story, :url => story_suggest_path(@story.short_id),
<%= form_with model: @story, :url => story_suggest_path(@story.short_id),
:method => :post, :html => { :id => "edit_story" } do |f| %>
<%= render :partial => "stories/form", :locals => { :story => @story,
:f => f, :suggesting => true } %>
@ -12,7 +12,7 @@
<div class="box">
<div class="boxline actions">
<%= submit_tag "Suggest Changes" %>
<%= f.submit "Suggest Changes" %>
&nbsp;or <a href="<%= story_path(@story.short_id) %>">cancel</a>
</div>
</div>

View File

@ -1,4 +1,4 @@
<%= form_for @tag, url: @tag.persisted? ? update_tag_path : tags_path, method: :post do |f| %>
<%= form_with mode: @tag, url: @tag.persisted? ? update_tag_path : tags_path, method: :post do |f| %>
<div class="boxline">
<%= f.label :tag, 'Name:', class: 'required' %>
<%= f.text_field :tag %>

View File

@ -5,24 +5,24 @@ if they cause problems. Please use your discretion when inviting persons you
don't personally know.
</p>
<%= form_tag invitations_path, :method => :post do |f| %>
<%= form_with url: invitations_path, :method => :post do |f| %>
<% if defined?(return_home) && return_home %>
<%= hidden_field_tag :return_home, 1 %>
<%= f.hidden_field :return_home, 1 %>
<% end %>
<div class="boxline">
<%= label_tag :email, "E-mail Address:", :class => "required" %>
<%= email_field_tag :email, "", :size => 30, :autocomplete => "off" %>
<%= f.label :email, "E-mail Address:", :class => "required" %>
<%= f.email_field :email, :size => 30, :autocomplete => "off" %>
</div>
<div class="boxline">
<%= label_tag :memo, "Memo to User:", :class => "required" %>
<%= text_field_tag :memo, "", :size => 60 %>
<%= f.label :memo, "Memo to User:", :class => "required" %>
<%= f.text_field :memo, :size => 60 %>
</div>
<div class="boxline">
<p></p>
<%= submit_tag "Send Invitation" %>
<%= f.submit "Send Invitation" %>
</div>
<% end %>

View File

@ -169,14 +169,14 @@
<%= render partial: 'mod_notes/table', locals: {
mod_notes: ModNote.for(@showing_user).limit(10),
} %>
<%= form_for @mod_note, method: :post do |f| %>
<%= form_with model: @mod_note, method: :post do |f| %>
<%= error_messages_for @mod_note %>
<%= f.hidden_field :username %>
<div class="boxline">
<%= f.label :note, "New Note:", :class => "required" %>
<%= f.text_area :note, :style => "width: 500px;", :rows => 5 %>
</div>
<div class="boxline"><p></p><%= submit_tag "ModNote" %></div>
<div class="boxline"><p></p><%= f.submit "ModNote" %></div>
<% end %>
<label class="required">Last 10 Moderations:</label>
@ -214,13 +214,13 @@
</table>
<% if @showing_user.is_banned? || @showing_user.banned_from_inviting? %>
<%= form_tag user_unban_path, :method => :post do %>
<%= form_with url: user_unban_path, :method => :post do |f| %>
<p>
<% if @showing_user.is_banned? %>
<%= submit_tag "Unban" %>
<%= f.submit "Unban" %>
<% end %>
<% if @showing_user.banned_from_inviting? %>
<%= submit_tag "Enable Invites", formaction: user_enable_invite_path %>
<%= f.submit "Enable Invites", formaction: user_enable_invite_path %>
<% end %>
</p>
<% end %>
@ -231,17 +231,17 @@
Banning or disabling invites for a user will send an e-mail to the user with the reason below,
with your e-mail address as the Reply-To so the user can respond.
</p>
<%= form_tag user_ban_path, :method => :post do %>
<%= form_with url: user_ban_path, :method => :post do |f| %>
<div class="boxline">
<%= label_tag :reason, "Reason:", :class => "required" %>
<%= text_field_tag :reason, "", :size => 40 %>
<%= f.label :reason, "Reason:", :class => "required" %>
<%= f.text_field :reason, :size => 40 %>
</div>
<p>
<% if !@showing_user.is_banned? %>
<%= submit_tag "Ban", class: 'deletion' %>
<%= f.submit "Ban", class: 'deletion' %>
<% end %>
<% if !@showing_user.banned_from_inviting? %>
<%= submit_tag "Disable Invites", formaction: user_disable_invite_path %>
<%= f.submit "Disable Invites", formaction: user_disable_invite_path %>
<% end %>
</p>
<% end %>

View File

@ -0,0 +1,23 @@
module RuboCop
module Cop
module Style
class DisallowFormForandFormTag < Cop
MSG = 'Use `.form_with` and remove the `.form_tag` and `.form_for`'.freeze
def_node_matcher :form_for_exists?, <<-PATTERN
(send _ :form_for ...)
PATTERN
def_node_matcher :form_tag_exists?, <<-PATTERN
(send _ :form_tag ...)
PATTERN
def on_send(node)
return unless form_for_exists?(node) || form_tag_exists?(node)
add_offense(node)
end
end
end
end
end