我的控制器中有索引方法,有一行:
@channels = Channel.where("user_id = ?", current_user.id)
我使用 gem“Haml-rails”,我有这样的视图: index.html.haml
- provide(:title, "Channels")
.offset1
= @channels.each do |channel|
Channel name:
= channel.name
%br
Url:
%a
= channel.url
%br
= link_to "Change", edit_channel_path(channel)
|
= link_to "Delete", channel, method: :delete,
data: { confirm: "Are you sure?" }
%br
它的工作原理,但在查看它输出有关模型的信息:
[#<Channel id: 1, name: "tut.by", url: "http://tut.by/rss/rss.all", created_at: "2013-09-13 11:21:14", updated_at: "2013-09-13 11:21:14", user_id: 17>, #<Channel id: 2, name: "youtube.com", url: "http://youtube.com/rss/rss.all", created_at: "2013-09-13 11:54:50", updated_at: "2013-09-13 11:54:50", user_id: 17>]
我不明白为什么这是输出