Commit 34942df5 by Ngô Trung Hưng

use link_to_if

parent 3ed7b149
Pipeline #887 canceled with stages
in 0 seconds
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
/public/assets /public/assets
.byebug_history .byebug_history
.env
# Ignore master key for decrypting credentials and more. # Ignore master key for decrypting credentials and more.
/config/master.key /config/master.key
/lib/csv /lib/csv
...@@ -45,6 +45,7 @@ gem 'bootsnap', '>= 1.1.0', require: false ...@@ -45,6 +45,7 @@ gem 'bootsnap', '>= 1.1.0', require: false
group :development, :test do group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console # Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'dotenv-rails'
end end
group :development do group :development do
......
...@@ -94,6 +94,10 @@ GEM ...@@ -94,6 +94,10 @@ GEM
railties (>= 4.1.0) railties (>= 4.1.0)
responders responders
warden (~> 1.2.3) warden (~> 1.2.3)
dotenv (2.7.6)
dotenv-rails (2.7.6)
dotenv (= 2.7.6)
railties (>= 3.2)
draper (4.0.1) draper (4.0.1)
actionpack (>= 5.0) actionpack (>= 5.0)
activemodel (>= 5.0) activemodel (>= 5.0)
...@@ -253,6 +257,7 @@ DEPENDENCIES ...@@ -253,6 +257,7 @@ DEPENDENCIES
chromedriver-helper chromedriver-helper
coffee-rails (~> 4.2) coffee-rails (~> 4.2)
devise devise
dotenv-rails
draper draper
jbuilder (~> 2.5) jbuilder (~> 2.5)
kaminari kaminari
......
# frozen_string_literal: true
class RegistrationsController < Devise::RegistrationsController class RegistrationsController < Devise::RegistrationsController
def after_inactive_sign_up_path_for(resource) def after_inactive_sign_up_path_for(resource)
confirm_sign_up_path(code: 2) confirm_sign_up_path(code: 2)
end end
def after_update_path_for(resource)
my_page_path
end
end end
...@@ -2,15 +2,11 @@ ...@@ -2,15 +2,11 @@
# User controller # User controller
class UsersController < ApplicationController class UsersController < ApplicationController
before_action :authenticate_user!, only: :my_page
def confirm_sign_up def confirm_sign_up
render :confirm render :confirm
end end
def my_page def my_page
if user_signed_in?
render :my_page
else
redirect_to root_path
end
end end
end end
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
<ul> <ul>
<% resource.errors.full_messages.each do |message| %> <% resource.errors.full_messages.each do |message| %>
<li><%= message %></li> <li><%= message %></li>
<% flash[:error] = 'Vui lòng kiểm tra lại thông tin' %>
<% end %> <% end %>
</ul> </ul>
</div> </div>
......
...@@ -15,21 +15,16 @@ ...@@ -15,21 +15,16 @@
<li class="list_item_menu_header_right"> <li class="list_item_menu_header_right">
<%= link_to 'History', '#', class: 'link_item_menu_header_right' %> <%= link_to 'History', '#', class: 'link_item_menu_header_right' %>
</li> </li>
<% if user_signed_in? %> <li class="list_item_menu_header_right">
<li class="list_item_menu_header_right"> <%= link_to_if(user_signed_in?, 'My page', my_page_path, class: 'link_item_menu_header_right') do
<%= link_to 'My page', my_page_path, class: 'link_item_menu_header_right' %> link_to 'Sign in', new_user_session_path, class: 'link_item_menu_header_right'
</li> end %>
<li class="list_item_menu_header_right"> </li>
<%= link_to 'Log out', destroy_user_session_path, method: :delete, class: 'link_item_menu_header_right' %> <li class="list_item_menu_header_right">
</li> <%= link_to_if(user_signed_in?, 'Log out', destroy_user_session_path, method: :delete, class: 'link_item_menu_header_right') do
<% else %> link_to 'Register', new_user_registration_path, class: 'link_item_menu_header_right'
<li class="list_item_menu_header_right"> end %>
<%= link_to 'Sign in', new_user_session_path, class: 'link_item_menu_header_right' %> </li>
</li>
<li class="list_item_menu_header_right">
<%= link_to 'Register', new_user_registration_path, class: 'link_item_menu_header_right' %>
</li>
<% end %>
</ul> </ul>
</div> </div>
<%# mobile %> <%# mobile %>
...@@ -44,22 +39,16 @@ ...@@ -44,22 +39,16 @@
<li class = "item_menu_mobile_vertical"> <li class = "item_menu_mobile_vertical">
<%= link_to 'History', '#', class: 'link_item_menu_mobile' %> <%= link_to 'History', '#', class: 'link_item_menu_mobile' %>
</li> </li>
<li class="item_menu_mobile_vertical">
<% if user_signed_in? %> <%= link_to_if(user_signed_in?, 'My page', my_page_path, class: 'link_item_menu_mobile') do
<li class = "item_menu_mobile_vertical"> link_to 'Sign in', new_user_session_path, class: 'link_item_menu_mobile'
<%= link_to 'My page', my_page_path, class: 'link_item_menu_mobile' %> end %>
</li> </li>
<li class = "item_menu_mobile_vertical"> <li class="item_menu_mobile_vertical">
<%= link_to 'Log out', destroy_user_session_path, method: :delete, class: 'link_item_menu_mobile' %> <%= link_to_if(user_signed_in?, 'Log out', destroy_user_session_path, method: :delete, class: 'link_item_menu_mobile') do
</li> link_to 'Register', new_user_registration_path, class: 'link_item_menu_mobile'
<% else %> end %>
<li class = "item_menu_mobile_vertical"> </li>
<%= link_to 'Sign in', new_user_session_path, class: 'link_item_menu_mobile' %>
</li>
<li class = "item_menu_mobile_vertical">
<%= link_to 'Register', new_user_registration_path, class: 'link_item_menu_mobile' %>
</li>
<% end %>
</ul> </ul>
</div> </div>
<div> <div>
......
...@@ -10,14 +10,18 @@ ...@@ -10,14 +10,18 @@
<hr> <hr>
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-12">
<span>Email: <%= user_signed_in? ? current_user.name : 'N/A'%> </span> <span>Email: <%= current_user.email %> </span>
</div> </div>
<div class="col-lg-12"> <div class="col-lg-12">
<span>Name: <%= user_signed_in? ? current_user.email : 'N/A'%></span> <span>Name: <%= current_user.name %></span>
</div> </div>
<div class="col-lg-12"> <div class="col-lg-12">
CV: <%= link_to user_signed_in? ? current_user.cv.identifier : 'N/A', current_user.cv.url, target: '_blank', class: 'link_ct pdf' %> <% if current_user.cv.identifier %>
<%= link_to '<i class="fas fa-download"></i>'.html_safe, current_user.cv.url, download: current_user.cv.identifier %> CV: <%= link_to current_user.cv.identifier, current_user.cv.url, target: '_blank', class: 'link_ct pdf' %>
<%= link_to '<i class="fas fa-download"></i>'.html_safe, current_user.cv.url, download: current_user.cv.identifier %>
<% else %>
CV: <span class="link_ct">No file</span>
<% end %>
</div> </div>
<hr> <hr>
<div class="col-lg-6"> <div class="col-lg-6">
......
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
config.action_mailer.default_url_options = { host: 'localhost', port: 1234 } config.action_mailer.default_url_options = { host: 'localhost', port: 1234 }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
user_name: ENV['SENDMAIL_USERNAME'],
password: ENV['SENDMAIL_PASSWORD'],
domain: ENV['MAIL_HOST'],
address: 'smtp.gmail.com',
port: '587',
authentication: :plain,
enable_starttls_auto: true
}
# In the development environment your application's code is reloaded on # In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development # every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes. # since you don't have to restart the web server when you make code changes.
......
Rails.application.configure do Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb. # Settings specified here will take precedence over those in config/application.rb.
config.action_mailer.default_url_options = { host: 'hungnt-venjob.herokuapp.com' }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
user_name: ENV['SENDMAIL_USERNAME'],
password: ENV['SENDMAIL_PASSWORD'],
domain: 'hungnt-venjob.herokuapp.com',
address: 'smtp.gmail.com',
port: '587',
authentication: :plain,
enable_starttls_auto: true
}
# Code is not reloaded between requests. # Code is not reloaded between requests.
config.cache_classes = true config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and # Eager load code on boot. This eager loads most of Rails and
......
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