<%= link_to 'My Appointments',
appointment_path(current_user.appointment) if current_user.appointment
%> The problem is current_user.appointment is returing more than one
appointments. So if u re concerned about the last ap then do this:
current_user.appointment.last
On 7 Jul 2016 1:14 p.m., "Ruth Stephenson" <[email protected]> wrote:

> I have a users (Devise) and apointments table. I want to add a link in
> my application.html.erb to link to that particular user's appointment,
> so they can have the option to change it. (As a customer).
>
> I have a similar link set up for them to edit their profile.
>
> <%= link_to 'My Appointments',
> appointment_path(current_user.appointment) if current_user.appointment
> %>
>
> Profile works:
> <%= link_to 'My Profile', profile_path(current_user.profile) if
> current_user.profile %>
>
>
> However the appointments link won't work. It gives the error:
> Couldn't find Appointment with
>
> 'id'=#<Appointment::ActiveRecord_Associations_CollectionProxy:0x007ffaa5999b28>
>
> Appointment belongs to user
> user has many appointments
> profile belongs to user
> user has one profile
>
> My code is as follows:
>
>
>  def index
>     @appointments = Appointment.all
>   end
>
>
>   def show
>     @appointment = Appointment.find(params[:id])
>
>   end
>
>   def new
>     @appointment = Appointment.new
>   end
>
> --
> 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/e5ecd6b53c92eedb2aeded777552ac49%40ruby-forum.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAHewxcGkty2_ZetU7HXLRe3t8iUg4Z9St6AJ-DYR98YjCKCeBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to