gpt4 book ai didi

ruby-on-rails - 闪光[:notice] displaying extra character

转载 作者:太空宇宙 更新时间:2023-11-03 17:34:09 27 4
gpt4 key购买 nike

我遇到了一个奇怪的问题,我的 flash[:notice] 显示了一个额外的/随机字符(“0”)。我不知道它是从哪里来的。

Controller :

  def edit
@subject = Subject.find_by(id: params[:id])
end

def update
@subject = Subject.find_by(id: params[:id])
if @subject.update_attributes(strong_params)
flash[:notice] = 'Subject has been updated'
redirect_to action: 'show', id: @subject.id
else
render 'edit'
end
end

def delete
@subject = Subject.find_by(id: params[:id])
end

private

def strong_params
params.require(:subject).permit(:name, :position, :visible)
end

查看:

   = if !flash[:notice].blank?
.notice
= flash[:notice]
%h2 Update subject
= form_for :subject, :url => {action: 'update', id: @subject.id} do |f|
= f.label :name, 'Name:'
= f.text_field :name
= f.label :position, 'Position:'
= f.text_field :position
= f.label :visible, 'Visible:'
= f.text_field :visible
= f.submit 'Update Subject'


%h2
Are you sure you want to delete the subject - #{@subject.name}
= link_to 'Yes, delete!', action: 'destroy', id: @subject.id

最佳答案

因此,事实证明答案是:将“大声”haml = if !flash[:notice].blank? 更改为“silent”- if !flash[:notice ].空白?.

关于ruby-on-rails - 闪光[:notice] displaying extra character,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23143867/

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