Re: How to display error in view for an instance

renu mehta
2012-07-03T17:05:35Z

Walter Davis wrote in post #1067201:
> On Jul 3, 2012, at 1:59 AM, renu mehta wrote:
>
>>
>> instance in the array?
> What do you see if you iterate over the members of the array, like this
> (in a view, just for debugging purposes)?
>
>   <%- @member_list.each do |member| %>
>   <%= member.inspect %>
>   <%- end %>
>
> I am guessing that each member will carry its own hash of errors, and
> you should see them when you do this. Then it''s just a matter of
> iterating them in your view to build the error list per member.
>
> Walter

This is what I get:

#<Member family_member_id: nil, member_first_name: "",
member_last_name:
"", security_question_answer: nil, created_at: nil, updated_at: nil,
member_gender: nil, member_dob: nil, security_question_id: nil,
native_language: "", family_id: nil, is_child: false, is_family_head:
false, member_middle_name: "", member_email: nil, relation_name:
"",
marital_status: nil>

But nothing about errors. And following code in the loop does not show
anything.

<% member.errors.full_messages.each do |msg| %>

<%= msg %>
    <% end %>

--
Posted via http://www.ruby-forum.com/.