Hallo 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 wie komme ich an die Photodaten? Die sollten doch in product enthalten sein! <%=product.photos.filename %> ..undefined method `filename Filename ist aber drin. Gruß Werner
on 2009-02-22 15:40
on 2009-02-22 15:45
On Sun, 22 Feb 2009 15:39:33 +0100 Werner Laude <newsgroup@wernerlaude.de> wrote: > Hallo hallo werner, > > <% 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
on 2009-02-22 15:57
Danke soweit.. @ Daniel => gute Quelle Gruß Am 22.02.2009 um 15:44 schrieb Rene Paulokat:
on 2009-02-22 18:36
Jep. Aber glaube hatte mit deinem Problem konkret nichts zu tun. Ich hatte letzens auch ein ein "merkwürdiges" Problem mit dem routing. Fand das da auch sehr gut erklärt. Generell ist die Seite zu empfehlen. Werner Laude schrieb:
on 2009-02-22 20:40
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 2009-02-22 22:13
Hi Werner, probier mal "debug" statt "puts". "puts" sollte nicht in einer Rails-Anwendung verwendet werden. Grüße Nicolai
on 2009-02-22 22:34
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: > > > Noch mal einen Hinweis wäre super.. >>> Hallo >>> >> >> rene >>> rubyonrails-ug@headflash.com >> > > _______________________________________________ > rubyonrails-ug mailing list > rubyonrails-ug@headflash.com > 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: roman@sladeczek.de
on 2009-02-22 23:07
Am 22.02.2009 um 22:33 schrieb Roman Sladeczek: Danke.. wenn man zu lange brütet, sieht man die einfachen Lösungen nicht.. Gruß
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.