I am struggling with a simple join query using postgres and SEQUEL with ruby.
I have table 1 (shortlists) with columns: id, shortname
and table 2 (shortmembers) with columns: id, short_id (references to the id of shortlists)
I want to select shortmembers id and shortlists shortname. So, in regular SQl, it would be
SELECT shortlists.shortname, shortmembers.id WHERE shortmembers.short_id = shortlists.id
I have tried
@shortmembers = DB[:shortlists].join(:shortmembers, :id => :short_id)
and then ruby code:
<option value="">Populated Shortlists ..</option>
<% @shortmembers.each do |shortmember| %>
<option value="<%= shortmember[:id] %>"><%= shortmember[:shortname] %></option>
<% end %>
I get an error message which leads me to suppose the join query is not working. It is:
undefined method `each' for nil:NilClass
All help gratefully received!