Skip to content

Instantly share code, notes, and snippets.

@3h5a9
Created April 30, 2019 14:45
Show Gist options
  • Select an option

  • Save 3h5a9/6dd0c65e290ee505a103a62ad24b3675 to your computer and use it in GitHub Desktop.

Select an option

Save 3h5a9/6dd0c65e290ee505a103a62ad24b3675 to your computer and use it in GitHub Desktop.
How to remove field_with_errors wrapper in Rails
/*Add the following line of codes into config/environemnt.rb file*/
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance|
html_tag.html_safe
end
@deOliveiraDiego
Copy link
Copy Markdown

This don't resolve my problem. I don't know why. Can you help me?

@3h5a9
Copy link
Copy Markdown
Author

3h5a9 commented May 17, 2020

@deOliveiraDiego can you please tell me where did u get the error?
Thank you

@deOliveiraDiego
Copy link
Copy Markdown

Hi!
I discovered where was my problem. I didn't restart my server. That's all. But, thanks! 😄

@3h5a9
Copy link
Copy Markdown
Author

3h5a9 commented May 18, 2020

@deOliveiraDiego good job done man.
have a nice day.

@danchulesku
Copy link
Copy Markdown

@deOliveiraDiego

Thank you dude!

@searls
Copy link
Copy Markdown

searls commented Jan 30, 2023

For anyone who stumbles on this via Google, I'd recommend editing this on your application's configuration object instead of duck-punching the proc on ActionView::Base itself.

That could mean in config/application.rb:

    config.action_view.field_error_proc = proc do |html_tag, instance|
      html_tag.html_safe
    end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment