Topic: associations problem on

I can't figure out how to do this. Using the appointments example here (2.4) http://guides.rubyonrails.org/association_basics.html

How would I set up the new view for appointments? I'm stuck on the routing problem as well. Let's say in this example that it's an app for doctors offices. So patients and physicians belong_to office.

My routes say

resources :office do
    resources :patients
    resources :physicians
    resources :appointments

I thought I could do domain.com/offices/id/appointments/new

Then on the new view

    <%= simple_form_for :appointments do |u| %>

    <%= u.association :physicians, :as => :radio %>
    <%= u.association :patients, :as => :radio %>

    <%= u.input :app_date %>
    <%= u.input :app_description %>

    <%= u.button :submit %>
    <% end %>

I get "Association cannot be used in forms not associated with an object" error

My appointments controller

  def new
    @office = current_user.offices.find_by_id(params[:office_id])
    @patients = @office.patients
    @physicians = @office.physicians
    @appointments = @office.appointments.build

Last edited by 71 (2013-02-01 19:37:48)