-
-
Save creativereason/3299581 to your computer and use it in GitHub Desktop.
class Lead < ActiveRecord::Base | |
attr_accessible :address, :city, :company, :email, :job_title, :name, :phone_number, :state | |
validates :name, :presence => true | |
validates :email, :presence => true, :format => { :with => /\A[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\z/, | |
:message => "Valid email only" } | |
validates :company, :presence => true | |
end |
Comes back as you'd expect.
=> ["Name can't be blank", "Email can't be blank", "Email Valid email only", "Company can't be blank"]
So I guess then remove all your javascript and render a console.log("<%= escape_javascript @lead.errors.full_messages %>");
Getting this error:
ActionView::Template::Error (undefined method `gsub' for #<Array:0x007fa7544a1d68>):
(Referencing that line:
console.log("<%= escape_javascript @lead.errors.full_messages %>");
This finally spit it out to the console:
<% @lead.errors.full_messages.each do |error_text| %>
console.log("<%= escape_javascript error_text %>");
<% end %>
Did that display the proper text? I'm wondering if maybe they weren't properly escaped?
Yes. I know I had them escaped before. I'll try another option at putting them back on the page.
Thanks.
You might try $('#error_explanation').append('<%=content_tag(:, escape_javascript(msg))%>');
I'm missing the p in the content_tag.
Also the escape_javascript might make sense wrapping the content_tag instead too, I'm not sure.
Could you give me the output of this in the console?