create func login logout mypage
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
-
-
-
1 <% if resource.errors.any? %> 2 <div id="error_explanation"> 3 <ul> 4 <% resource.errors.full_messages.each do |message| %> 5 <li><%= message %></li> 6 <% flash[:error] = 'Vui lòng kiểm tra lại thông tin' %> -
MasterEdited
Dòng này để làm gì, có cần thiết không ?
-
Master
Chỗ này em định hiển thị thêm thông báo dạng toast
-
-
-
6 6 base_title = 'VenJob' 7 7 page_title.empty? ? base_title : "#{base_title} | #{page_title}" 8 8 end 9 10 def custom_bootstrap_flash 11 flash_messages = [] 12 flash.each do |type, message| 13 type = 'success' if type == 'notice' 14 type = 'error' if type == 'alert' 15 text = "<script>toastr.#{type}('#{message}');</script>" 16 flash_messages << text.html_safe if message -
Master
Khi
messagecó tồn tại giá trị thì mới thêm vàoflash_messages.Vậy thì nên kiểm tra điều kiện này ban đầu trước khi thực hiện các xử lý khác
flash.each do |type, message| next if message.blank? # Other logic end
-
-
app/controllers/users_controller.rb 0 → 100644
1 # frozen_string_literal: true 2 3 # User controller 4 class UsersController < ApplicationController 5 def confirm_sign_up 6 render :confirm 7 end 8 9 def my_page 10 if user_signed_in? -
Master
Dùng ternary operator hoặc guard clause
Guard clause:
return redirect_to root_path unless user_signed_in? render :my_page -
-
-
13 <%= link_to 'Yêu thích', '#', class: 'link_item_menu_header_right' %> 13 <%= link_to 'Favorite', '#', class: 'link_item_menu_header_right' %> 14 14 </li> 15 15 <li class="list_item_menu_header_right"> 16 <%= link_to 'Lịch sử', '#', class: 'link_item_menu_header_right' %> 17 </li> 18 <li class="list_item_menu_header_right"> 19 <%= link_to 'Đăng nhập', '#', class: 'link_item_menu_header_right' %> 20 </li> 21 <li class="list_item_menu_header_right"> 22 <%= link_to 'Đăng ký', '#', class: 'link_item_menu_header_right' %> 16 <%= link_to 'History', '#', class: 'link_item_menu_header_right' %> 23 17 </li> 18 <% if user_signed_in? %> 19 <li class="list_item_menu_header_right"> 20 <%= link_to 'My page', my_page_path, class: 'link_item_menu_header_right' %> -
Master
Thử sử dụng
link_to_if -
Master
dạ anh
-
-
-
-
-
Toggle commit list
-
Toggle commit list
-
merged
Toggle commit list