refactor controller

parent 4a80d625
Pipeline #1402 failed with stages
in 0 seconds
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: %i[name cv])
devise_parameter_sanitizer.permit(:account_update, keys: %i[name cv])
end
end end
# frozen_string_literal: true # frozen_string_literal: true
class Users::RegistrationsController < Devise::RegistrationsController class Users::RegistrationsController < Devise::RegistrationsController
before_action :configure_sign_up_params, only: [:create] # before_action :configure_sign_up_params, only: [:create]
before_action :configure_account_update_params, only: [:update] # before_action :configure_account_update_params, only: [:update]
# before_action :configure_permitted_parameters, if: :devise_controller?
def show def show
end end
...@@ -57,7 +56,7 @@ class Users::RegistrationsController < Devise::RegistrationsController ...@@ -57,7 +56,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
# end # end
def after_update_path_for(resource) def after_update_path_for(resource)
my_path my_path(resource)
end end
# The path used after sign up for inactive accounts. # The path used after sign up for inactive accounts.
...@@ -65,12 +64,12 @@ class Users::RegistrationsController < Devise::RegistrationsController ...@@ -65,12 +64,12 @@ class Users::RegistrationsController < Devise::RegistrationsController
register_2_path register_2_path
end end
# If you have extra params to permit, append them to the sanitizer. # If you have extra params to permit, append them to the sanitizer.
def configure_sign_up_params # def configure_sign_up_params
devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :cv]) # devise_parameter_sanitizer.permit(:sign_up, keys: [:name, :cv])
end # end
def configure_account_update_params # def configure_account_update_params
devise_parameter_sanitizer.permit(:account_update, keys: [:name, :cv]) # devise_parameter_sanitizer.permit(:account_update, keys: [:name, :cv])
end # end
end end
...@@ -9,7 +9,7 @@ Rails.application.routes.draw do ...@@ -9,7 +9,7 @@ Rails.application.routes.draw do
post 'confirm', to: 'apply_jobs#confirm' post 'confirm', to: 'apply_jobs#confirm'
post 'done', to: 'apply_jobs#done' post 'done', to: 'apply_jobs#done'
devise_for :users, controllers: { registrations: 'users/registrations', confirmations: 'users/confirmations', devise_for :users, controllers: { registrations: 'users/registrations', confirmations: 'users/confirmations',
passwords: 'users/passwords', sessions: 'users/sessions' }, skip: [:sessions, :registrations, :passwords] passwords: 'users/passwords', sessions: 'users/sessions' }, skip: %i[sessions registrations passwords]
resources :user resources :user
get '/my', to: 'users#show' get '/my', to: 'users#show'
devise_scope :user do devise_scope :user do
...@@ -17,10 +17,10 @@ Rails.application.routes.draw do ...@@ -17,10 +17,10 @@ Rails.application.routes.draw do
get 'register/2', to: 'users/registrations#show' get 'register/2', to: 'users/registrations#show'
get 'my/info', to: 'users/registrations#edit', as: :edit_user_registration get 'my/info', to: 'users/registrations#edit', as: :edit_user_registration
match '/my', to: 'devise/registrations#create', as: :user_registration, via: [:post] match '/my', to: 'devise/registrations#create', as: :user_registration, via: [:post]
match '/my', to: 'devise/registrations#update', via: [:put, :patch] match '/my', to: 'devise/registrations#update', via: %i[put patch]
get 'forgot_password', to: 'users/passwords#new', as: :new_user_password get 'forgot_password', to: 'users/passwords#new', as: :new_user_password
get 'reset_password', to: 'users/passwords#edit', as: :edit_user_password get 'reset_password', to: 'users/passwords#edit', as: :edit_user_password
match 'reset_password', to: 'users/passwords#update', via: [:put, :patch] match 'reset_password', to: 'users/passwords#update', via: %i[put patch]
match 'reset_password', to: 'users/passwords#create', as: :user_password, via: [:post] match 'reset_password', to: 'users/passwords#create', as: :user_password, via: [:post]
get 'login', to: 'users/sessions#new', as: :new_user_session get 'login', to: 'users/sessions#new', as: :new_user_session
post 'login', to: 'users/sessions#create', as: :user_session post 'login', to: 'users/sessions#create', as: :user_session
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment