Hi Andrew and Curtis,
     I've been away for 3 days but have come back to the problem
above.
        As things have continued to be difficult I have backed off
keeping things well normalized and have crunched the people_skills
table, with its 3 fields of: skill, competency and years of
experience, into the people table.  This still leaves another table,
employee_infos, in a one-one relationship with people which is still
not printing on the same screen as people.  Here are the models in
question:

class Person < ActiveRecord::Base
        default_scope :order => 'last_name'
        has_one :EmployeeInfo
        has_one :CandidateInfo
        has_one :EmploymentHistory

        validates :first_name, :presence => true
        validates :last_name, :presence => true
        validates :email, :presence => true
end

class EmployeeInfo < ActiveRecord::Base
        belongs_to :person
end

The people_controller.rb#index, where I want to see the proper data,
is:

 def index
    @people = Person.all
    @employee_infos = EmployeeInfo.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @people }
    end
  end

And a relevant section of index.html.erb is:
 <%= @people.each do |person| %>
  <tr>
...
    <td><%= person.zip_code %></td>
    <td><%= person.skill_set %></td>
    <td><%= WHAT GOES HERE TO BE ABLE TO PRINT THE "position" FIELD OF
THE employee_infos TABLE? WHAT CHANGES SHOULD BE MADE TO THE ABOVE?

     A second point was made about not having SQL statements in the
controller (which I have done) so what is the alternative?  What pages
can I go to to see some examples of the right way?
     Thanks again,
          Barney


On Jul 21, 7:48 pm, Curtis Schofield <[email protected]> wrote:
> > I still can't help feeling you are experiencing these issues because you are
> > starting to swim upstream against the rails conventions.
>
> One of the unspoken conventions being violated is putting Queries in the 
> Controller - :(
>
> > If you are still having difficulty, please post you model logic as well -
> > especially the relationships between the objects (belongs_to, has_many, etc)
>
> This is a really good suggestion. Spending time expressing the logic and what 
> your purpose is
> will increase the quality of help that you get - and likely reduce 
> frustration.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to