ja hallo erstmal,.,.. Am Sonntag, 30. Dezember 2007 schrieb Jan Roesner: > Hallo Leute, > > ich möchte in einer Action ein Model validieren und im negativen Falle > via rjs ein Alert mit allen Flashmeldungen generieren. > > In meiner action: > > @error = "Es gab Fehler: " > @valid = true > > if not @bid.valid? > @valid = false > for msg in flash[:all] > @error = @error + msg > end > end > > Im .rjs: > > if @valid > page.call 'alert', 'Alles OK!' > else > page.call 'alert', @error > end > > Allerdings kommt im Negativfall kein Javascript zurück, weil: > > NoMethodError (You have a nil object when you didn't expect it! > You might have expected an instance of Array. > The error occured while evaluating nil.each): > > Irgendwie komme ich nicht an den flash Hash heran. Ich stehe hier > gerade auf dem Schlauch, kann mir jemand helfen?
Warum willst Du an den flash? Was spricht gegen @bid.errors ? z.B. @bid.errors.on(:price) vgl. http://api.rubyonrails.org/classes/ActiveRecord/Errors.html Keep smiling yanosz _______________________________________________ rubyonrails-ug mailing list [email protected] http://mailman.headflash.com/mailman/listinfo/rubyonrails-ug
