I’ve compiled a guide on generating options
tags using options_for_select
.
Environment
- Ruby 2.2.3
- Rails 4.2.5
I’ve compiled a guide on generating options
tags using options_for_select
.
How to write for
loop in CoffeeScript.
In Ruby, it is written as items.each
.
1 2 3 4 |
arr = ['a', 'b', 'c'] for item in arr alert item |
In Ruby, it is written as items.each_with_index
.
1 2 3 4 5 |
arr = ['a', 'b', 'c'] for item, index in arr alert index alert item |
Here’s the code to realise nl2br
of PHP in Rails.
(Unless Rails changes considerably), it can be used in most versions.