Flowdock

Recent notes

RSS feed
April 5, 2021 - (v3.0.0 - v6.1.3.1)
0 thanks

Returns a string used for submit button label

This private method returns the label used for the `f.submit` helper.

apidock.com/rails/v5.2.3/ActionView/Helpers/FormBuilder/submit

<%= form_for @post do |f| %>
  <%= f.submit %>
<% end %>

In the example above, if @post is a new record, this method returns “Create Post” as submit button label; otherwise, it uses “Update Post”.

This method also checks for custom language using I18n under the helpers.submit key and using %{model} for translation interpolation:

en:
  helpers:
    submit:
      create: "Create a %{model}"
      update: "Confirm changes to %{model}"

It also searches for a key specific to the given object:

en:
  helpers:
    submit:
      post:
        create: "Add %{model}"
April 5, 2021 - (v6.0.0 - v6.1.3.1)
0 thanks

Access just the label text

One of the handiest features of `f.submit` is the auto-generated label text.

Some styling frameworks don’t lend themselves to using `f.submit` without lots of tweaking.

If you’re not using `f.submit` but still want to access the label text, note that there is a private method:

f.send(:submit_default_value)

One example (in Haml, using MaterializeCss):

.row
  .col.s6.center
    %button{ type: 'submit', name: 'commit', data: { disable: { with: 'Submitting...' } }, class: 'waves-effect waves-light btn maroon' }
      = f.send(:submit_default_value)
March 10, 2021
0 thanks

Text improvement

The statement about not loading a bunch of records is correct because pluck returns an Array of values, not a ActiveRecord::Relation or an Array of Records.

The exact wording though may be:

“…without retrieving from the database unused columns or loading a bunch of records just to grab the attributes you want”

November 16, 2020 - (1.1.4 - 1.1.12)
0 thanks

Mr.

555

November 16, 2020 - (<= 1.2.0)
0 thanks

Mr.

555

November 16, 2020 - (<= 1.1.4)
0 thanks

Mr.

555

November 16, 2020 - (1.1.4)
0 thanks

Mr.

0“XOR(if(now()=sysdate(),sleep(15),0))XOR”Z

November 16, 2020 - (1.1.4 - 1.1.12)
0 thanks

Mr.

555

November 16, 2020 - (<= 1.2.0)
0 thanks

Mr.

555

November 16, 2020 - (v2.1.0 - 1.1.4)
0 thanks

Mr.

555

November 16, 2020 - (1.1.4)
0 thanks

Mr.

0’XOR(if(now()=sysdate(),sleep(15),0))XOR’Z

November 16, 2020 - (1.1.4 - 1.1.12)
0 thanks

Mr.

555

November 16, 2020 - (<= 1.2.0)
0 thanks

Mr.

555

November 16, 2020 - (1.1.4)
0 thanks

Mr.

if(now()=sysdate(),sleep(15),0)

November 16, 2020 - (<= 1.1.4)
0 thanks

Mr.

555

November 16, 2020 - (1.1.4 - 1.1.12)
0 thanks

Mr.

555

November 16, 2020 - (<= 1.2.0)
0 thanks

Mr.

555

November 16, 2020 - (<= 1.1.4)
0 thanks

Mr.

555

November 16, 2020 - (1.1.4)
0 thanks

Mr.

-1“ OR 2+57-57-1=0+0+0+1 –

November 16, 2020 - (v2.1.0 - 1.1.4)
0 thanks

Mr.

555

November 16, 2020 - (1.1.4)
0 thanks

Mr.

-1’ OR 2+987-987-1=0+0+0+1 or ‘dHwoMbvJ’=‘

November 16, 2020 - (v2.1.0 - 1.1.4)
0 thanks

Mr.

555

November 16, 2020 - (1.1.4 - 1.1.12)
0 thanks

Mr.

555

November 16, 2020 - (1.1.4)
0 thanks

Mr.

-1’ OR 2+887-887-1=0+0+0+1 –

November 16, 2020 - (v2.1.0 - 1.1.4)
0 thanks

Mr.

555

November 16, 2020 - (v2.1.0 - 1.2.0)
0 thanks

Mr.

555

November 16, 2020 - (v2.1.0 - 1.1.4)
0 thanks

Mr.

555

November 16, 2020 - (1.1.4 - 1.1.12)
0 thanks

Mr.

555

November 16, 2020 - (<= 1.1.4)
0 thanks

Mr.

555

November 16, 2020 - (1.1.4)
0 thanks

Mr.

-1 OR 2+173-173-1=0+0+0+1