From ca81e4813a6bd7131e2f5c3a50a010565f8fc96b Mon Sep 17 00:00:00 2001 From: Hugo Peixoto Date: Fri, 31 Mar 2023 02:35:11 +0100 Subject: [PATCH] Add query params to members#new --- app/controllers/members_controller.rb | 6 +++++- app/views/members/new.html.erb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index dcaec8f..37fa43d 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -16,7 +16,7 @@ class MembersController < ApplicationController # GET /members/new def new - @member = Member.new + @member = Member.new(get_params) end # GET /members/1/edit @@ -66,4 +66,8 @@ class MembersController < ApplicationController def member_params params.fetch(:member, {}).permit(:display_name, :legal_name, :pronouns, :email, :identification_number, :category, :address, :joined_on, :expires_on, :wants_mailing_list, :prefers_postal) end + + def get_params + params.permit(:display_name, :legal_name, :pronouns, :email, :identification_number, :category, :address, :joined_on, :expires_on, :wants_mailing_list, :prefers_postal) + end end diff --git a/app/views/members/new.html.erb b/app/views/members/new.html.erb index 72cdfe1..55beea9 100644 --- a/app/views/members/new.html.erb +++ b/app/views/members/new.html.erb @@ -18,7 +18,7 @@ <%= form.text_field :legal_name, required: true %> <%= form.text_field :pronouns %> <%= form.email_field :email, required: true %> - <%= form.select :category, %w{student retired unemployed employed} %> + <%= form.select :category, %w{student retired unemployed employed}, { include_blank: true }, { required: true } %> <%= form.text_field :identification_number %> <%= form.text_area :address %> <%= form.check_box :wants_mailing_list %>