Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 有关视图中模型的不必要信息_Ruby On Rails_View - Fatal编程技术网

Ruby on rails 有关视图中模型的不必要信息

Ruby on rails 有关视图中模型的不必要信息,ruby-on-rails,view,Ruby On Rails,View,我的控制器中有索引方法,我有一行: @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:

我的控制器中有索引方法,我有一行:

@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>] 
[#,#]
我不明白为什么这是输出

您应该更改

= @channels.each do |channel|
#The equals character is followed by Ruby code. 
#This code is evaluated and the output is inserted into the document.

你应该改变

= @channels.each do |channel|
#The equals character is followed by Ruby code. 
#This code is evaluated and the output is inserted into the document.