I have a model called Student that has the University_ID attribute in it.
I created a custom action and route that displays information about a particular student at the following link: students/2/details ie students/:id/details
However, I want to be able to allow the user to use their university identifier instead of the database identifier, for example, the following: students/X1234521/details i.e. students/:university_id/details
Currently, my route file is as follows:
resources :students match 'students/:id/details' => 'students#details', :as => 'details'
However, this uses Student_ID as opposed to University_ID, and I tried doing
match 'students/:university_id/details' => 'students#details', :as => 'details' ,: match 'students/:university_id/details' => 'students#details', :as => 'details' , but this only matches Student_ID, not University_ID.
My controller looks like this if it helps anyway:
def details @student = Student.find(params[:id]) end
I also tried doing @student = Student.find(params[:university_id]) , but nothing, nothing worked.