Hello! I’m pulling my hair out trying to get a simple view to display
correctly.
I need to display the practice info for each of the providers in my
database. Each provider has multiple practices. I would like the
second, third, fourth … provider_id, location and provider_no to
line up under the first provider_id, location, etc.
My problem is that each additional practice is added as a new row,
aligned with the left margin, instead of under the appropriate header.
I don’t know if this is an html issue, or a ror issue. Because I’m
dangerously newbie.
This is what the view looks like:
All Providers:
Title First Name Last Name License ID Location Provider Number
Dr Tom Close MD 4 RTH T01
Dr Evan Spam MD 5 RTH T02
Dr Ted Blue MD 6 RTH T10
6 RMC N07
Dr Jack Horner MD 7 RMC N09
7 RTH T10
Dr John Left MD 8 RMC N34
8 RTH T14
This is the view file [lookup.rhtml]:
All Providers:
Title
First Name
Last Name
License
ID
Location
Provider Number
<% for provider in @providers %>
<%= provider.title %>
<%= provider.first_name %>
<%= provider.last_name %>
<%= provider.lic_type %>
<% for practice in provider.practices %>
<%= practice.provider_id %>
<%= practice.location %>
<%= practice.provider_no %>
<% end %>
<% end %>
Here are the models:
class Provider < ActiveRecord::Base
has_many :identifiers
has_many :practices
end
class Practice < ActiveRecord::Base
belongs_to :provider
end
Here is the related providers_controller def:
def lookup @providers = Provider.find(:all, :include =>[:practices])
end
Any insight anyone could provide would be most welcome. Thank you!