I have the following migrations:

Sequel.migration do
  up do
    create_table(:courses) do
      primary_key :id
      foreign_key :instructor_id
      String :term, size: 5, null: false
      String :name, size: 8, null: false
      String :section, size: 3
      String :building, size: 32
      String :meeting_days, size: 6
      String :start_time, size: 8
      String :end_time, size: 8
      Integer :transfer, default: 0
    end
  end

  down do
    drop_table(:courses)
  end
end

Sequel.migration do
  up do
    create_table(:faculties) do
      primary_key :id
      String :name, null: false
      String :email, size: 80, null: false
    end
  end

  down do
    drop_table(:faculties)
  end
end

as you can see they have a field that share the same name: 'name'. I also 
have the following corresponding Models

class Faculty < Sequel::Model
    one_to_many :courses, key: :instructor_id
end

and

class Course < Sequel::Model
    many_to_one :instructor, :class => :Faculty
end

When I run the following command: Course.join(Faculty, :id=> 
:instructor_id).sql I obtain: 
"SELECT * FROM `courses` INNER JOIN `faculties` ON (`faculties`.`id` = 
`courses`.`instructor_id`)" 

Since I am actually joining the model Course with the model Student (from 
left to right) I know that I should be expecting an array of Course 
instances, which I am fine with it.

Here is the problem for any element of this array, let us say course, 
course.name containes the name of the Faculty joined not the name of the 
course, why is that? what am I doing wrong and how to fix this problem?

Heberto del Rio

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-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].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to