ArgumentError (wrong number of arguments (2 for 0)):

Can anyone tell me why I am getting this error using rails3 and
Ruby1.9.2:-

Completed 200 OK in 212313ms (Views: 2.8ms | ActiveRecord: 0.0ms)
Homepage Load (0.2ms) SELECT “homepages”.* FROM “homepages” WHERE
(“homepages”.“section” = ‘%Gar%’)

ArgumentError (wrong number of arguments (2 for 0)):


In my model I have:-
self.where(‘section <= ?’, “%#{search_item}%”)
or
self.where(:section => “%#{search_item}%”)

I am making an ajax call using a form_tag. “Gar” is being passed to
“search_item”

In my controller I have:-
def index

@homepages = Homepage.search(params[:search])
respond_to do |format|
  format.html # index.html.erb
  format.xml  { render :xml => @homepages }
  format.js {render :js => @homepages}
end

Just a guess on my part, but it looks as if you may want to produce a
LIKE condition in the resultant sql - if so, perhaps something like
(no pun intended ) this will work:

self.where(‘section LIKE ?’, “%#{search_item}%”)

Thanks Dennis you were right

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs