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
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
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}%")
> ArgumentError (wrong number of arguments (2 for 0)):
> ******************************************************************
> In my model I have:-
> self.where(''section <= ?'',
"%#{search_item}%")
> or
> self.where(:section => "%#{search_item}%")
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks Dennis you were right On Oct 31, 6:39 pm, Dennis <dennismaj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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}%") > > > ArgumentError (wrong number of arguments (2 for 0)): > > ****************************************************************** > > In my model I have:- > > self.where(''section <= ?'', "%#{search_item}%") > > or > > self.where(:section => "%#{search_item}%")-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.