[英]Ruby on rails wrong number of arguments
my code for search:controller: 我的搜索代码:controller:
class WelcomeController < ApplicationController
def index
@index=self.index(params:[:search])
end
end
view: 视图:
<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>
model 模型
class Welcome < ActiveRecord::Base
def self.search(search)
if search
where('name LIKE ?', "%#{search}%")
else
scoped
end
end
end
can you please help me and let me know where I am going wrong,I am getting a wrong number of arguments error
and I am new to Ruby on rails, can someone please help. 你能不能帮助我,让我知道我哪里出错了,我得到
wrong number of arguments error
,我是Ruby on rails的新手,有人可以帮忙。
I think your controller should be: 我认为你的控制器应该是:
class WelcomeController < ApplicationController
def index
@index = Welcome.search(params[:search])
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.