jeudi 9 juillet 2015

path helper issue in rails 3

I am migrating a application from rails 2.3 to rails 3.1, i am using a path helper like student_teacher_path(@student,teacher.id), this used to work in rails 2.3 even if teacher.id is nil i mean it did not generate a exception in 2.3.

But with rails 3.1 i am getting a exception like ActionView::Template::Error (No route matches {:action=>"show", :controller=>"teachers", :student_id=>#<Student id:>,nil})

How do i handle this in rails 3.1. Is there any better way to this other than using a if else and check if teacher.id is nil and display data accordingly.

Any suggestion will be appreciated, Thanks.

Aucun commentaire:

Enregistrer un commentaire