Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 Rails errors.full_消息呈现方括号_Ruby On Rails 3 - Fatal编程技术网

Ruby on rails 3 Rails errors.full_消息呈现方括号

Ruby on rails 3 Rails errors.full_消息呈现方括号,ruby-on-rails-3,Ruby On Rails 3,我正在使用以下HAML遍历用户#更新中的错误: - if @user.errors.any? .alert.alert-error %ul = @user.errors.full_messages.each do |msg| %li= msg 但是,除了显示消息之外,我还得到了方括号: 名字不能为空[“名字不能为空”] 我做错了什么 编辑: 如果我做了p msg,则控制台尾部仅显示消息,但在中,括号仍然呈现。我找到了答案 该行: =@user.error

我正在使用以下HAML遍历
用户#更新中的错误:

- if @user.errors.any?
  .alert.alert-error
    %ul
      = @user.errors.full_messages.each do |msg|
        %li= msg
但是,除了显示消息之外,我还得到了方括号:

名字不能为空[“名字不能为空”]

我做错了什么

编辑:

如果我做了
p msg
,则控制台尾部仅显示消息,但在
  • 中,括号仍然呈现。

    我找到了答案

    该行:

    =@user.errors.full_messages.each do| msg |

    应该读到:

    -@user.errors.full_messages.each do | msg |

    哈姆在做循环的同时打印出了数组