Commit 71dc2fcf by nnnghia98

change route

parent d927cd18
class Users::AdminsController < ApplicationController
class AdminsController < ApplicationController
before_action :authenticate_user!, only: :index
def index
......@@ -14,7 +14,7 @@ class Users::AdminsController < ApplicationController
def get_applied_jobs
if params[:search_user]
user = User.find_by(email: params[:search_user])
return redirect_to users_admin_path, notice: "User/job not found!" if user.blank?
return redirect_to admin_path, notice: "User/job not found!" if user.blank?
applied_jobs = user.jobs
applied_jobs.page(params[:page]).per(Settings.job.per_page)
......
......@@ -37,6 +37,6 @@ class User < ApplicationRecord
:recoverable, :rememberable, :validatable
def self.list_emails
@emails ||= self.all.pluck(:email)
@emails ||= all.pluck(:email)
end
end
<h4>Search user's applied jobs:</h4>
<%= form_tag(users_admin_path, method: :get) do |f| %>
<%= form_tag(admin_path, method: :get) do |f| %>
<%= select_tag :search_user, options_for_select(User.list_emails, params[:search_user]), include_blank: "Choose user's email" %>
<%= submit_tag "Search" %>
<% end %>
......
......@@ -14,11 +14,11 @@ Rails.application.routes.draw do
devise_for :users
root "tops#index"
namespace :users do
get "admin", to: "admins#index", as: :admin
resource :my_page, only: :show do
collection do
get "jobs", action: :applied_jobs, as: :applied_jobs
end
end
end
get "admin", to: "admins#index", as: :admin
end
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