Use AngularJS on Rails form_for


I used AngularJS on Rails form_for. The most annoying thing is form_for generates form tag with action attribute.

Environment

  • Rails 4.1.8
  • Ruby 2.2.2
  • AngularJS 1.4.7
  • Ubuntu 15.04

Circumstance

Rails form_for generates form tag with some attributes, including action. Of course, we can add other attributes. But, AngularJS conflicts with this.

In the following code, problem occurs.

After clicking the button, AngularJS process will be executed and original form process will be executed.

AngularJS prevent original process when form doesn’t have action attribute, but rails add action attributes automatically. I couldn’t find the way to prevent rails from adding action attribute.

Solution

Add onsubmit="return false;" to the form tag.

また AngularJS: How to prevent form submission after click on button? に記載されているような方法もありますが、 javascript として 他のところで使えないので、 上に書いたやり方の方がきれいに見えます。


Proof: Infinite Decimal of Rational Number is Recurring Decimal


I prove that infinite decimal of rational number is recurring decimal. It is decimal of rational number but is not finite decimal.

While the process of division may seem intuitive, I will provide a more concrete explanation as a formal proof.

Feeling

For example, when 89 is sequentially divided by 13, including decimal places, the remainders are as follows:

\begin{eqnarray*} 89 \div 13 & = & 6 \; \textrm{remainder is} 11 \\ 110 \div 13 & = & 8 \; \textrm{remainder is} 6 \\ 60 \div 13 & = & 4 \; \textrm{remainder is} 8 \\ 80 \div 13 & = & 6 \; \textrm{remainder is} 2 \\ 20 \div 13 & = & 1 \; \textrm{remainder is} 7 \\ 70 \div 13 & = & 6 \; \textrm{remainder is} 5 \\ 50 \div 13 & = & 3 \; \textrm{remainder is} 11 \\ 110 \div 13 & = & 8 \; \textrm{remainder is} 6 \end{eqnarray*}

On the 7th division, the same remainder as in the 1st division appeared again. Since there are only 12 possible remainers when divided by 13, ranging from 1 to 12, if the division doesn’t result in a perfect quotient after 13 divisions, it becomes evident that at some point, the same remainder would recur, leading to a repeating decimal.

Continue reading Proof: Infinite Decimal of Rational Number is Recurring Decimal

A Life Summary of an Gypsy