Being my first ever live project, I wanted to concentrate on every aspect and detail to deliver my best. The Project was Peatio, which is a core, open-source Crypto-currency, and digital asset exchange platform is built and implemented on the Rails framework (Ruby on Rails) and other advanced technologies and server components. It was a huge project, with a prominent client which meant a huge responsibility as a newbie. I was fortunate enough to get a supportive mentor throughout the project.
Technologies Stack for the Project:
Ruby - 2.5.1, Rails – 4 Database – MYSQL
During this project, I worked on multiple modules but the one I found fascinating and challenging was “To Login into User’s Account”. In this module, the admin can log in to the user’s account but in reading mode through the user's email address or id.
To complete this module, I made use of the session variable.
Step 1: - Saving the session of admin role in one session variable.
Step 2: - Fetching and save the user id in another session variable.
Step 3: -Finally replacing the new user session variable with the current session variable by placing proper conditions to execute it in read-only mode.
if admin_user? (Checking for user is already admin or not)
flash[:notice] = 'Already a Admin User'
session[:admin_id] = current_user.id (Step 1)
user_id = User.find_by(id: params[:id]) (Step 2)
session[:user_id] = user_id (Step 2)
session[:current_id] = session[:user_id] (Step 3)
redirect_to root_path (Redirect to Welcome page)