
Untitled
By: a guest on
Aug 11th, 2012 | syntax:
None | size: 1.00 KB | hits: 6 | expires: Never
Rendering joined array to display Rails Errors
if @person.errors.blank? && @person.save
flash[:info] = "Your profile has been successfully updated."
redirect_to profile_url(@person) and return
else
if @person.errors.on(:first_name).is_a?(Array)
@person.errors.on(:first_name).join
end
flash[:warning] = "Sorry, there was a problem saving your profile. Please try again."
render :edit
end
%li
= label(:person, :first_name, "First Name")
= f.text_field :first_name
- if @person.errors[:first_name].present?
%span{:style => "color: red; margin-left: 180px;"}= @person.errors[:first_name]
if @person.errors.present?
@person.errors.each do |err|
= err
if @person.save
flash[:info] = "Your profile has been successfully updated."
redirect_to profile_url(@person)
else
@person.errors[:first_name] = @person.errors.on(:first_name).to_a.join
flash[:warning] = "Sorry, there was a problem saving your profile. Please try again."
render :edit
end