Hallo Werner,

warum so kompliziert?

hast Du es schon mal damit probiert?

<% for photo in @product.photos%>
        <%=photo.filename%>
<%end%>

Gruss,
Roman

Am 22.02.2009 um 20:40 schrieb Werner Laude:


Am 22.02.2009 um 15:44 schrieb Rene Paulokat:

Hallo Rene..und ...

ich muß nochmal nachfragen..

Die Listenansicht klappt soweit, aber die Produkt Einzelansicht noch nicht.
Produkt hat zwei Bilder

show
<%= finde_small(@product.id) %>

Ich habe hier nur die product_id

Habe dann einen Helper geschrieben

def finde_small(small)
all_smalls = Photo.find(:all, :conditions=>["product_id = ?", small.to_i])

Das gibt auch zwei Rauten zurück, soweit so gut

all_smalls.each {| sma | sma.filename}

müßte er hier nicht die beiden filenames aus dem array zeigen?
Leider nicht.. nur die beiden Rauten.


all_smalls.each {| sma | puts sma.filename} => broken pipe

Noch mal einen Hinweis wäre super..

Gruß
Werner





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


_______________________________________________
rubyonrails-ug mailing list
[email protected]
http://mailman.headflash.com/listinfo/rubyonrails-ug

Roman Sladeczek
Consulting & IT
Voßstr. 4
81543 München
TEL.: +49 89 54075045
Mobil: +49 163 7348177
Email: [email protected]




_______________________________________________
rubyonrails-ug mailing list
[email protected]
http://mailman.headflash.com/listinfo/rubyonrails-ug

Antwort per Email an