Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

field_error_proc 'error_message undefined method' in rails 3.pre

#4078

I am trying to override the field_error_proc:

ActionView::Base.field_error_proc = Proc.new do |html, instance|
%(#{html} #{instance.error_message}) end

but it throws this error:

ActionView::Template::Error (undefined method error_message' for #<ActionView::Helpers::InstanceTag:0x0000010361b798>)

Has error_message been changed/deprecated?

Reported by Cam Caine · March 1st, 2010 @ 03:35 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. ieuser
    ieuser

    it works but outputs safe html instead of the raw version

    ActionView::Base.field_error_proc = Proc.new { |html_tag, instance|
    "

    try to add raw and it doesnt like it..

    March 10th, 2010 @ 10:41 PM

  2. Cam Caine
    Cam Caine
    • Tag set to actionview

    I think if you try adding .html_safe on the string output it works, but I am more concerned with getting what was instance.error_message but now errors.on is [] I dont see how to get it?

    March 10th, 2010 @ 11:33 PM

  3. YoNoSoyTu
    YoNoSoyTu

    I have the same problem:

    undefined method error_message' for #<ActionView::Helpers::InstanceTag:0x40be40c>

    Looking at the code (both Rails-3.0.0.beta and Edge in GitHub) at the bottom of active_model_helper.rb (http://github.com/rails/rails/blob/master/actionpack/lib/action_vie...) you can see that ActiveRecordInstanceTag has not that method defined.

    I have prepared a patch which fixes the omission and includes a test.

    March 15th, 2010 @ 06:18 PM

  4. Repository