SELECT i.inumber as itemid, i.ititle as title, i.ibody as body, m.mname as author, m.mrealname as authorname, i.itime, i.imore as more, m.mnumber as authorid, m.memail as authormail, m.murl as authorurl, c.cname as category, i.icat as catid, i.iclosed as closed FROM nucleus_item as i, nucleus_member as m, nucleus_category as c WHERE i.iblog=1 and i.iauthor=m.mnumber and i.icat=c.catid and i.idraft=0 and i.itime<="2008-12-05 04:11:53" and inumber=46 ORDER BY i.itime DESC LIMIT 0,1
stdClass Object
(
[itemid] => 46
[title] => Rails: Printing validation errors as flash notices
[body] => I am quite sure someone has already found this simple solution, but when I poked around, I couldn't find it.
Here is my snippet to print out the error messages resulting from a validation as a flash notice:
if @user.save
flash[:'notice'] = "New user saved successfully."
elsif !@user.errors.empty?
flash[:'notice'] = "Could not save new user: "
<< @user.errors.full_messages.join("; ")
end
[author] => erin
[authorname] => Erin Schnabel
[itime] => 2006-07-11 18:43:00
[more] =>
[authorid] => 1
[authormail] => erinschnabel@gmail.com
[authorurl] => http://ebullientworks.com/
[category] => General
[catid] => 1
[closed] => 0
)
Tuesday, 11 July 2006
Rails: Printing validation errors as flash notices
I am quite sure someone has already found this simple solution, but when I poked around, I couldn't find it.
Here is my snippet to print out the error messages resulting from a validation as a flash notice:
if @user.save
flash[:'notice'] = "New user saved successfully."
elsif !@user.errors.empty?
flash[:'notice'] = "Could not save new user: "
<< @user.errors.full_messages.join("; "
end
posted by
erin at 06:43 PM
in
General
tags:
ruby /
rails