Hiho,
yep, I'm a newbie I can't get this to work.
I have the classes "Wishlist" and "User".
class Wishlist < ActiveRecord::Base belongs_to :owner, :class_name => "User", :foreign_key => "user_id" has_and_belongs_to_many :visitors, :class_name => "User" end
class User < ActiveRecord::Base has_many :wishlists has_and_belongs_to_many :observations, :class_name => "Wishlist" end
and this (partial) schema.rb:
ActiveRecord::Schema.define(:version => 4) do create_table "users", :force => true do |t| t.string "name" [...] end
create_table "users_wishlists", :id => false, :force => true do |t| t.integer "user_id" t.integer "wishlist_id" end
create_table "wishlists", :force => true do |t| t.integer "user_id" [...] end
end
Now, when I do something like this in my view:
<% for ll in @current_user.observations %> <li> <%= ll.owner.name %> <%= ll.titel %> von <%= ll.owner.name %> <% end %>
the "owner" of ll is not set correctly but to @current_user
WHAT am I doing wrong? I am quite lost.
Thanks for your help, Olav