Ruby on rails错误的参数数量

时间:2014-05-02 12:54:12

标签: html ruby-on-rails search arguments

我的搜索代码:controller:

class WelcomeController < ApplicationController
  def index
    @index=self.index(params:[:search])
  end
end

视图:

<center>
<h2> Search </h2>

<form id=”search-form” name=”search” method=”get” action=”index.html”>

<input id=”s” type=”text” name=”s” placeholder=”Search…”>

<input id=”search-button-1″ type=”submit” name=”search-button-1″>

</form>

模型

class Welcome < ActiveRecord::Base
    def self.search(search)
        if search
         where('name LIKE ?', "%#{search}%")
        else
         scoped
        end
   end
end

你能帮助我,让我知道我哪里出错了,我得到一个wrong number of arguments error我是Ruby的新手,有人可以帮忙。

1 个答案:

答案 0 :(得分:2)

我认为你的控制器应该是:

class WelcomeController < ApplicationController
  def index
    @index = Welcome.search(params[:search])
  end
end