gpt4 book ai didi

ruby-on-rails - Rails 表单标签大小写问题

转载 作者:数据小太阳 更新时间:2023-10-29 08:44:32 25 4
gpt4 key购买 nike

在我的用户 Controller 的显示 View 中,我遇到了用户名未在 label 标记中大写的问题。代码是

<%= form_for(@user) do |f| %>
<%= render 'shared/error_messages', object: f.object %>

<%= f.label "Assign " + @user.name + " to" %>
<%= f.collection_select :id, @ders, :id, :name %>
<% end %>

当使用 @user.name 调用时,用户名在 form_for block 外显示为 Example User,但在 block 内它显示为 example user。这是为什么?

最佳答案

尝试更改为 <%= f.label :id, "Assign #{@user.name} to" %> , :id是用于 for 的值标签上的属性。

关于ruby-on-rails - Rails 表单标签大小写问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34120968/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com