content_columns returns nothing

I have a model "wanted_offers" that's defined as a "belongs_to" with another model. All that wanted_offers has is two foreign keys in two columns.

I've implemented a show method and passing in the id of the wanted_offer that the user clicks on.

The method is not displaying anything. The "<% for column in WantedOffer.content_columns %>" isn't executing.

When I look at the database, it looks as expected with two rows.

Me again... I suppose Ruby is doing the RIGHT thing by returning null on content_columns call since the child doesn't have any content per se - it just holds two foreign keys. So maybe I can restate my Q...

How do I get at a parent of WantedOffer in this type of call? <% for column in WantedOffer.content_columns %>

nahabed,

I'm not sure that rendering for .content_columns is something you'd want to do in production. It may get things out quickly for development but I'd suspect you will quickly want more control that what that will allow.

As to your real question... I'm making an assumption from the keys in your wanted_offers db that you might be able to build your classes like this:

class User   has_many :wanted_offers

has_many :wanted_books :through=>:wanted_offers, :class_name=>'Book',   ... end

(You should mirror this in Book)

With that in place you should be able to do something like this:

@user.wanted_books.each do |book|   book.content_columns.each do |book_column|      ...whatever it is you were trying to do...   end end

HTH, AndyV