This document explains how the user application system works in the StudErn platform.
The system allows users to apply to recruitments (jobs, internships, micro-jobs, micro-internships) that meet specific criteria:
- Payment Verification: The recruitment must have a completed payment with a valid transaction ID
- Easy Apply Method: The recruitment must be set to use the "easy_apply" application collection method
- Open Status: The recruitment must be open for applications
- User Profile: The user must have a complete profile
- Associations:
belongs_to :user,belongs_to :recruitment - Validations:
- Unique user per recruitment (prevents duplicate applications)
- Recruitment must be open for applications
- Recruitment must have completed payment with valid transaction ID
- Recruitment must use easy_apply method
- User must have complete profile
- Status Enum:
pending,accepted,rejected,withdrawn
- Associations:
has_many :recruitment_applies,has_many :applied_recruitments - Helper Methods:
has_complete_profile?: Checks if user account status is completecan_apply_to_recruitment?(recruitment): Checks if user can apply to a specific recruitment
- Helper Methods:
can_accept_applications?: Checks if recruitment meets all criteria for accepting applicationsuser_can_apply?(user): Checks if a specific user can apply to this recruitmentapplication_deadline_passed?: Checks if application deadline has passed
apply_to_recruitment: Handles user application submissionwithdraw_application: Allows users to withdraw pending applicationsapplications: Shows user's application history
get "/user/applications", to: "users#applications", as: :user_applications
post "/user/recruitment/:recruitment_id/apply", to: "users#apply_to_recruitment", as: :user_apply_to_recruitment
patch "/user/application/:application_id/withdraw", to: "users#withdraw_application", as: :user_withdraw_application- Shows apply button only for recruitments that meet criteria
- Different states: "Apply Now", "Already Applied", "Cannot Apply", "Sign in to Apply"
- Handles both authenticated and unauthenticated users
- Lists all user applications with status indicators
- Allows withdrawal of pending applications
- Shows application details and links to recruitment
- User Authentication: User must be signed in to apply
- Profile Completion: User must have complete profile (account_status: "complete")
- Recruitment Eligibility: Recruitment must meet all criteria:
application_collection_status: "open"application_collection_method: "easy_apply"- Has completed payment with valid transaction ID
- Application Submission: User submits application via POST request
- Validation: System validates all requirements
- Application Creation: If valid, creates RecruitmentApply record with status "pending"
The system ensures recruitments are only available for applications if:
bkash_paymentassociation existsbkash_payment.trx_idis present and not emptybkash_payment.trx_statusis "Completed"
- Unique Applications: Database-level unique index prevents duplicate applications
- Validation: Multiple validation layers ensure data integrity
- Authorization: Users can only apply to eligible recruitments
- Status Management: Applications can be withdrawn but not deleted
if recruitment.user_can_apply?(current_user)
# Show apply button
else
# Show appropriate message
end@application = current_user.recruitment_applies.build(recruitment: @recruitment)
if @application.save
# Success
else
# Handle errors
end@applications = current_user.recruitment_applies.includes(:recruitment).order(created_at: :desc)