ruby on rails - Form undefined method `html_safe' for nil:NilClass -



ruby on rails - Form undefined method `html_safe' for nil:NilClass -

i using next function display form error individual fields.

# error helper form def show_errors(object, field_name) if object.errors.messages[field_name][0].present? "<label class='error'>" + object.errors.messages[field_name][0] + "</label>" if object.errors.any? end end

i calling application helper class follows.

<%= show_errors(@category, :name).html_safe %>

when there no error getting next error.

undefined method `html_safe' nil:nilclass

if have no error, if block skips , show_errors returns nil. may want add together else homecoming "" before end in show_error. or check nil in helper.

ruby-on-rails function

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -