Add action PassportsController#create
This commit is contained in:
parent
369d01f650
commit
8604829a56
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class PassportsController < ApplicationController
|
||||
before_action :set_passport, except: :index
|
||||
before_action :set_passport, except: %i[index new create]
|
||||
|
||||
# GET /passports
|
||||
def index
|
||||
|
@ -13,6 +13,12 @@ class PassportsController < ApplicationController
|
|||
authorize @passport
|
||||
end
|
||||
|
||||
# GET /passports/new
|
||||
def new
|
||||
@passport = Passport.new
|
||||
authorize @passport
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_passport
|
||||
|
|
|
@ -5,6 +5,10 @@ class PassportPolicy < ApplicationPolicy
|
|||
true
|
||||
end
|
||||
|
||||
def create?
|
||||
true
|
||||
end
|
||||
|
||||
def permitted_attributes_for_create
|
||||
%i[
|
||||
surname given_name patronymic sex date_of_birth place_of_birth series
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<div class="container">
|
||||
<%= simple_form_for @passport do |f| %>
|
||||
<%= f.input :surname %>
|
||||
<%= f.input :given_name %>
|
||||
<%= f.input :patronymic %>
|
||||
<%= f.input :sex,
|
||||
as: :radio_buttons,
|
||||
collection: Passport.sexes.map { |k, v|
|
||||
[Passport.human_attribute_name("sex.#{k}"), v]
|
||||
} %>
|
||||
<%= f.input :date_of_birth, start_year: Date.today.year - 150,
|
||||
end_year: Date.today.year %>
|
||||
<%= f.input :place_of_birth %>
|
||||
<%= f.input :series %>
|
||||
<%= f.input :number %>
|
||||
<%= f.input :issued_by %>
|
||||
<%= f.input :unit_code %>
|
||||
<%= f.input :date_of_issue, start_year: Date.today.year - 150,
|
||||
end_year: Date.today.year %>
|
||||
|
||||
<%= f.button :submit %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -28,7 +28,7 @@ Rails.application.routes.draw do
|
|||
|
||||
resources :membership_applications, only: %i[new create]
|
||||
|
||||
resources :passports, only: %i[index show]
|
||||
resources :passports, only: %i[index show new create]
|
||||
|
||||
resources :telegram_bot_updates, only: :create
|
||||
end
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'GET /passports/new' do
|
||||
before do
|
||||
get '/passports/new'
|
||||
end
|
||||
|
||||
specify do
|
||||
expect(response).to have_http_status :ok
|
||||
end
|
||||
end
|
Reference in New Issue