Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8368345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:22:01+00:00 2026-06-09T13:22:01+00:00

When creating an appointment, for let say Organization ‘ABC’, I can also see physicians

  • 0

When creating an appointment, for let say Organization ‘ABC’, I can also see physicians that belongs to other organization. It suppose to only list physician from ‘ABC’ and not others. How should I go about this.

Thank you.

My Appointment form:

<%= simple_form_for(@appointment, :html => { :class => 'form-horizontal' }) do |f| %>
  <div class="form-inputs">
    <%= f.hidden_field :patient_id %>
    <%= f.association :physician, :label_method => :first_name, :include_blank => false, :as => :radio_buttons, :required => true %>
    <%= f.hidden_field :appointment_date, :value => DateTime.now  %>
    <%= f.hidden_field :organization_id, :value => current_user.organization_id%>
  </div>

  <div class="form-actions">
    <%= f.button :submit, "Create Appointment" %>
  </div>
<% end %>

My models:

/app/models/physician.rb

class Physician < ActiveRecord::Base
  has_many :appointments
  has_many :patients, :through => :appointments
  belongs_to :organization

  attr_accessible :physician_name, :organization_id
end

/app/models/appointment.rb

class Appointment < ActiveRecord::Base
  belongs_to :physician
  belongs_to :patient
  belongs_to :organization

  attr_accessible :physician_id, :patient_id, :appointment_date, :state, :organization_id
end

/app/models/patient.rb

class Patient < ActiveRecord::Base
  has_many :appointments
  has_many :physicians, :through => :appointments
  belongs_to :organization

  attr_accessible :patient_name, :organization_id
end

My Controllers:

/app/controllers/appointment_controller.rb

class AppointmentsController < ApplicationController
  def new
    @appointment = Appointment.new
    @appointment.patient_id = params[:patient_id]
  end

  def create
    @appointment = Appointment.new(params[:appointment])

    if @appointment.save
      flash[:notice] = "New appointment record created"
      redirect_to dashboards_path
    else
      render 'new'
    end
  end
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:22:02+00:00Added an answer on June 9, 2026 at 1:22 pm

    This is because simple_form does not know about your scopes. If you tell it:

    <%= f.association :phyisician %>
    

    it will simply list all available physicians in the database.

    The solution is to give it the collection of physicians you want to show, for example you could write:

    <%= f.association :physician,
                      :collection => @appointment.patient.organization.physicians,
                      :label_method => :first_name,
                      :include_blank => false,
                      :as => :radio_buttons,
                      :required => true %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an appointment in Outlook through java code. here I can set
I'm having some difficulties creating a javascript appointment style calendar. While it does render,
I am creating an Outlook 2003 version of a Outlook 2007 add-in for appointment
Creating liquid layouts is an immense pain. Now, I totally understand that tables should
I have a small problem. I am creating an appointment table where in the
Creating a calculator-like dialog, I noticed that quickly clicking on a button in IE
Creating an installer for possible remote systems so that if they do not have
I need to change the owner of an appointment record when creating a new
I am creating a calendar application. I have a Appointment table, and a Person
creating 20 viewcontrollers and calling them one after the other from the mainviewcontroller as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.