Thanks for your help, however it wont' work. I put <%= link_to 'My appointment',current_user.appointments.order(:appointment_date).last%> ERROR: SQLite3::SQLException: no such column: appointments.appointment_date: SELECT "appointments".* FROM "appointments" WHERE "appointments"."user_id" = ? ORDER BY "appointments"."appointment_date" DESC LIMIT 1
Walter Davis wrote in post #1184502: >> %> >> Appointment belongs to user >> user has many appointments > > This is why the link doesn't work. A user (current_user) does not have > _an_ appointment, she has _many_ appointments. If you want the latest > one, then use > > current_user.appointments.order(:appointment_date).last if > current_user.appointments.any? > > You could put that in a helper so it doesn't make your views so > ungainly. > > Walter -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/fcc891ac7f93f17fa89bf8c8ba4ff4fd%40ruby-forum.com. For more options, visit https://groups.google.com/d/optout.

