我正在学习Ruby和Rails.
我有一个Ruby on Rails项目,它跟踪服务器正在运行的作业.现在,当我手动创建一个新工作时,它宣布:
flash[:notice] = "Created job job number #{update.id}."
Run Code Online (Sandbox Code Playgroud)
我想将其#{update.id}转变为工作清单上的工作链接.
转到作业的URL 是闪存通知中显示的jobs/list?job=12341234 update.id.
是否可以将链接放入flash[:notice]声明中?或者我是否需要重新处理此消息的显示方式才能将其转换为链接?
在控制器中,我有以下flash消息:
flash[:notice] = %Q[Please #{view_context.link_to('create a new account', new_account_path)}, after that you will be able to create orders.].html_safe
Run Code Online (Sandbox Code Playgroud)
这是布局中的闪存区域:
<div id="main_flash_area">
<% flash.each do |name, msg| %>
<div class="alert text-center alert-info">
<a class="close" data-dismiss="alert">× ???????</a>
<%= msg %>
</div>
<% end %>
</div>
Run Code Online (Sandbox Code Playgroud)
它有点呈现为链接,但浏览器不会将其解析为链接.它显示为
Please <a href="/accounts/new">create a new account</a>, after that you will be able to create orders.
Run Code Online (Sandbox Code Playgroud)
生成的HTML:
<div id="main_flash_area">
<div class="alert text-center alert-info">
<a class="close" data-dismiss="alert">× ???????</a>
Please <a href="/accounts/new">create a new account</a>, after that you will …Run Code Online (Sandbox Code Playgroud)