On Sun, 22 Feb 2009 15:39:33 +0100
Werner Laude <[email protected]> wrote:

> Hallo

hallo werner,

> Zwei Tabellen
> 
> model product
> has_many :photos
> 
> model photo
> belongs_to :product
> 
> View:
> product => index
> 
> <% for product in @products %>
> 
> <%=product.photo.filename %>... undefined method `photo'
> 
> oder <%=product.photos %>.. keine Fehlermeldung, zeigt ne Raute

genau, bzw. ein object/array an.

> wie komme ich an die Photodaten? Die sollten doch in product enthalten  
> sein!

product.photos.each { |p| puts p.filename  }

ist ja ne has_many, bzw. one-to-many beziehung. entsprechend bekommst du ein 
array zurueck.

gruesse
rene


> 
> <%=product.photos.filename %>   ..undefined method `filename
> 
> Filename ist aber drin.
> 
> Gruß
> Werner
> _______________________________________________
> rubyonrails-ug mailing list
> [email protected]
> http://mailman.headflash.com/listinfo/rubyonrails-ug


-- 
take care not to get sucked into /dev/null
gpg --recv-keys 0F8DDFBB
_______________________________________________
rubyonrails-ug mailing list
[email protected]
http://mailman.headflash.com/listinfo/rubyonrails-ug

Antwort per Email an