simple_formによるフォーム作成の簡略化

gem 'simple_form'で最低限の記述でフォームを作成できる。

gem 'simple_form'
% bundle install
% rails generate simple_form:install
<%= simple_form_for @user do |f| %>
  <%= f.input :username, error: '半角英数字で' %>
  <%= f.input :email,    placeholder: 'user@domain.com' %>
  <%= f.input :sex,      as: :radio_buttons %>
  <%= f.button :submit %>
  # ラベルを付けてくれる
  # オプションで様々な入力のオプションを指定
<% end %>