Rails 打印查询结果以及视图中的 object 数据
Rails prints the query result along with the object data in the view
我想在 rails 中创建一个笔记本应用程序。我需要在索引视图中打印所有注释,所以下面是 haml 中的代码。
= @notes.each do |note|
%h1= link_to note.title, note
%p= time_ago_in_words(note.created_at)
问题是在显示笔记标题和创建时间后,最后打印查询结果(如下截图)。
只有在使用循环一次打印所有笔记时问题仍然存在。无法弄清楚是什么问题。提前致谢。
将=
更改为-
- @notes.each do |note|
如果你只是想遍历 @notes
使用 -
如果你想打印一些输出使用 =
- @notes.each do |note|
%h1= link_to note.title, note
%p= time_ago_in_words(note.created_at)
我想在 rails 中创建一个笔记本应用程序。我需要在索引视图中打印所有注释,所以下面是 haml 中的代码。
= @notes.each do |note|
%h1= link_to note.title, note
%p= time_ago_in_words(note.created_at)
问题是在显示笔记标题和创建时间后,最后打印查询结果(如下截图)。
将=
更改为-
- @notes.each do |note|
如果你只是想遍历 @notes
使用 -
如果你想打印一些输出使用 =
- @notes.each do |note|
%h1= link_to note.title, note
%p= time_ago_in_words(note.created_at)