From 7600e048a7da35f62d4627cea789f2ceb975866c Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 2 Dec 2018 22:00:01 +0500 Subject: [PATCH] Move HTML to partial --- app/views/passports/_form.html.erb | 25 +++++++++++++++++++++++++ app/views/passports/new.html.erb | 26 +------------------------- 2 files changed, 26 insertions(+), 25 deletions(-) create mode 100644 app/views/passports/_form.html.erb diff --git a/app/views/passports/_form.html.erb b/app/views/passports/_form.html.erb new file mode 100644 index 0000000..5e44aac --- /dev/null +++ b/app/views/passports/_form.html.erb @@ -0,0 +1,25 @@ +<%= simple_form_for passport do |f| %> + <%= f.simple_fields_for :passport_map do |ff| %> + <%= ff.input :surname %> + <%= ff.input :given_name %> + <%= ff.input :patronymic %> + <%= ff.input :sex, + as: :radio_buttons, + collection: PassportMap.sexes.keys.map { |sex| + [Passport.human_attribute_name("sex.#{sex}"), sex] + } %> + <%= ff.input :date_of_birth, start_year: Date.today.year - 150, + end_year: Date.today.year %> + <%= ff.input :place_of_birth %> + <%= ff.input :series %> + <%= ff.input :number %> + <%= ff.input :issued_by %> + <%= ff.input :unit_code %> + <%= ff.input :date_of_issue, start_year: Date.today.year - 150, + end_year: Date.today.year %> + <% end %> + + <%= f.input :images %> + + <%= f.button :submit %> +<% end %> diff --git a/app/views/passports/new.html.erb b/app/views/passports/new.html.erb index c776f3f..aa2b018 100644 --- a/app/views/passports/new.html.erb +++ b/app/views/passports/new.html.erb @@ -1,27 +1,3 @@
- <%= simple_form_for @passport do |f| %> - <%= f.simple_fields_for :passport_map do |ff| %> - <%= ff.input :surname %> - <%= ff.input :given_name %> - <%= ff.input :patronymic %> - <%= ff.input :sex, - as: :radio_buttons, - collection: PassportMap.sexes.keys.map { |sex| - [Passport.human_attribute_name("sex.#{sex}"), sex] - } %> - <%= ff.input :date_of_birth, start_year: Date.today.year - 150, - end_year: Date.today.year %> - <%= ff.input :place_of_birth %> - <%= ff.input :series %> - <%= ff.input :number %> - <%= ff.input :issued_by %> - <%= ff.input :unit_code %> - <%= ff.input :date_of_issue, start_year: Date.today.year - 150, - end_year: Date.today.year %> - <% end %> - - <%= f.input :images %> - - <%= f.button :submit %> - <% end %> + <%= render partial: 'form', locals: { passport: @passport } %>