[英]Ruby on rails wrong number of 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 on rails的新手,有人可以幫忙。
我認為你的控制器應該是:
class WelcomeController < ApplicationController
def index
@index = Welcome.search(params[:search])
end
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.