我的搜索代码: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的新手,有人可以帮忙。
答案 0 :(得分:2)
我认为你的控制器应该是:
class WelcomeController < ApplicationController
def index
@index = Welcome.search(params[:search])
end
end