Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.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 未显示rails模型,也未引发异常_Ruby On Rails_Ruby_Ruby On Rails 3_Railscasts - Fatal编程技术网

Ruby on rails 未显示rails模型,也未引发异常

Ruby on rails 未显示rails模型,也未引发异常,ruby-on-rails,ruby,ruby-on-rails-3,railscasts,Ruby On Rails,Ruby,Ruby On Rails 3,Railscasts,我跟随railscast在我的应用程序上实现搜索,但当提交搜索时, 页面呈现为空白 这是我的show.html.erb <div class"row"> <div class="span12"> <h1>Resultados para <%= @search.keywords %>: <%= @search.noticias.size %></h1> </div> </div

我跟随railscast在我的应用程序上实现搜索,但当提交搜索时, 页面呈现为空白

这是我的
show.html.erb

<div class"row">
    <div class="span12">
        <h1>Resultados para <%= @search.keywords %>: <%= @search.noticias.size %></h1>
    </div>
</div>
结束

这是html输出:

<h1>Resultados para : 0</h1>
实际上,搜索是保存在mongodb上的,所以我不认为我会遗漏任何地方的
关键字
,因为应用程序只在我将当前关键字保存到模型并显示当前搜索模型后才进行搜索

形式

<%= form_for Search.new, :html => { :class => "navbar-search pull-right"} do |f| %>
    <input type="text" class="span2 search-query" placeholder="Pesquisar notícias" name="search[keyword]">
<% end %>
{:class=>“导航栏搜索向右拉”}do | f |%>

由于您发布的railcast对非付费用户不可用,您可以发布表单吗?您是否缺少通知。全文搜索(参数[:关键字])
?您能否向我们展示控制器的
show
方法。。。我猜你不知何故没有提供关键词…@Vapire编辑。Zippie,我在我的edit上解释了搜索,你能发布表单吗?好的,粘贴表单后,我得到了它,它是name=“search[keyword]”,它是“keywords”。正如我所说,有些愚蠢的事情:)
class SearchesController < ApplicationController
  def new
    @search = Search.new
  end

  def create
    @search = Search.create!(params[:search])
    redirect_to @search
  end

  def show
    @search = Search.find params[:id]
  end
end
<%= form_for Search.new, :html => { :class => "navbar-search pull-right"} do |f| %>
    <input type="text" class="span2 search-query" placeholder="Pesquisar notícias" name="search[keyword]">
<% end %>