Hi! I would like to create a "custom" version of the "auto_complete_for" function, I took the source code, and altered it to my needs, and, off course, changed the name (from auto_complete_for to custom_auto_complete_for , just for testing purporses). But rails keep complaining that the new method doesn''t exits! I already did something similar with the "error_messages_for" function, and just wrote the new one in the application_helper.rb file, and just worked everywhere... but for the auto_complete_for function: I don''t know where to put it, I tried to put it in the helper, in the controller itself, and even in the model: no, it doesn''t work, like the function didn''t existed. Any ideas? Ildefonso Camargo --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On Oct 11, 10:24 pm, "soulhunter" <ildefonso.cama...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi! > > I would like to create a "custom" version of the "auto_complete_for" > function, I took the source code, and altered it to my needs, and, off > course, changed the name (from auto_complete_for to > custom_auto_complete_for , just for testing purporses). But rails keep > complaining that the new method doesn''t exits! > > I already did something similar with the "error_messages_for" function, > and just wrote the new one in the application_helper.rb file, and just > worked everywhere... but for the auto_complete_for function: I don''t > know where to put it, I tried to put it in the helper, in the > controller itself, and even in the model: no, it doesn''t work, like the > function didn''t existed. > > Any ideas? > > Ildefonso CamargoIf you want to override the standard ''auto_complete_for :action, :method'', all you have to do is define a method named ''auto_complete_for_action_method'' in your controller and skip the ''auto_complete_for'' line completely. _Kevin --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Hi! Thanks for your answer! On Oct 11, 11:09 pm, "_Kevin" <kevin.olbr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Oct 11, 10:24 pm, "soulhunter" <ildefonso.cama...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi! > > > I would like to create a "custom" version of the "auto_complete_for" > > function, I took the source code, and altered it to my needs, and, off > > course, changed the name (from auto_complete_for to > > custom_auto_complete_for , just for testing purporses). But rails keep > > complaining that the new method doesn''t exits! > > > I already did something similar with the "error_messages_for" function, > > and just wrote the new one in the application_helper.rb file, and just > > worked everywhere... but for the auto_complete_for function: I don''t > > know where to put it, I tried to put it in the helper, in the > > controller itself, and even in the model: no, it doesn''t work, like the > > function didn''t existed. > > > Any ideas? > > > Ildefonso Camargo > If you want to override the standard ''auto_complete_for :action, > :method'', all you have to do is define a method named > ''auto_complete_for_action_method'' in your controller and skip the > ''auto_complete_for'' line completely.Yes, I know, I already did that, but the thing is: I want to replace ALL the autocompletions in my project (more than 20), because I want to change the search conditions (from LIKE to ~* , and need to add some character substitution). Thus, I tried to define this method (for testing purporses): def custom_auto_complete_for(object, method, options = {}) define_method("auto_complete_for_#{object}_#{method}") do find_options = { :conditions => [ "#{method} ~* ? ", ''%'' + params[object][method].downcase + ''%''], :order => "#{method} ASC", :limit => 10 }.merge!(options) @items = object.to_s.camelize.constantize.find(:all, find_options) render :inline => "<%= auto_complete_result @items, ''#{method}'' %>" end end That is my first approach, but when I try to call it, rails would just say: undefined method `custom_auto_complete_for'' for ContribuyentesController:Class and the log says: NoMethodError (undefined method `custom_auto_complete_for'' for ContribuyentesController:Class): I defined the method in application_helper.rb , but I also tried to define it locally in the "contribuyentes_controller.rb" file: I get the same error. Thanks in advance, Ildefonso Camargo --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Hi, again. I just found this: http://www.sciwerks.com/blog/2006/09/25/multiple_auto_complete_plugin/ but I can''t download the plug-in :( . Does anybody has it?, the server just says: script/plugin install svn://sciwerks.com/home/sciwerks/public_svn/plugins/multiple_auto_complete svn: Can''t connect to host ''sciwerks.com'': Connection refused I would appreciate any help on this..... the plug-in clearly reimplements the auto_complete_for method, wich is exactly what I need to do. Thanks in advance, Ildefonso Camargo On Oct 12, 7:58 am, "soulhunter" <ildefonso.cama...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi! > > Thanks for your answer! > > On Oct 11, 11:09 pm, "_Kevin" <kevin.olbr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Oct 11, 10:24 pm, "soulhunter" <ildefonso.cama...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi! > > > > I would like to create a "custom" version of the "auto_complete_for" > > > function, I took the source code, and altered it to my needs, and, off > > > course, changed the name (fromauto_complete_forto > > > custom_auto_complete_for , just for testing purporses). But rails keep > > > complaining that the new method doesn''t exits! > > > > I already did something similar with the "error_messages_for" function, > > > and just wrote the new one in the application_helper.rb file, and just > > > worked everywhere... but for theauto_complete_forfunction: I don''t > > > know where to put it, I tried to put it in the helper, in the > > > controller itself, and even in the model: no, it doesn''t work, like the > > > function didn''t existed. > > > > Any ideas? > > > > Ildefonso Camargo > > If you want to override the standard ''auto_complete_for:action, > > :method'', all you have to do is define a method named > > ''auto_complete_for_action_method'' in your controller and skip the > > ''auto_complete_for'' line completely.Yes, I know, I already did that, but the thing is: I want to replace > ALL the autocompletions in my project (more than 20), because I want to > change the search conditions (from LIKE to ~* , and need to add some > character substitution). > > Thus, I tried to define this method (for testing purporses): > > def custom_auto_complete_for(object, method, options = {}) > define_method("auto_complete_for_#{object}_#{method}") do > find_options = { > :conditions => [ "#{method} ~* ? ", ''%'' + > params[object][method].downcase + ''%''], > :order => "#{method} ASC", > :limit => 10 }.merge!(options) > > @items = object.to_s.camelize.constantize.find(:all, find_options) > > render :inline => "<%= auto_complete_result @items, ''#{method}'' %>" > end > end > > That is my first approach, but when I try to call it, rails would just > say: > > undefined method `custom_auto_complete_for'' for > ContribuyentesController:Class > > and the log says: > > NoMethodError (undefined method `custom_auto_complete_for'' for > ContribuyentesController:Class): > > I defined the method in application_helper.rb , but I also tried to > define it locally in the "contribuyentes_controller.rb" file: I get the > same error. > > Thanks in advance, > > Ildefonso Camargo--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
I''ll check on it. _Kevin On Oct 13, 3:14 pm, "soulhunter" <ildefonso.cama...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, again. > > I just found this: > > http://www.sciwerks.com/blog/2006/09/25/multiple_auto_complete_plugin/ > > but I can''t download the plug-in :( . Does anybody has it?, the server > just says: > > script/plugin install > svn://sciwerks.com/home/sciwerks/public_svn/plugins/multiple_auto_complete > svn: Can''t connect to host ''sciwerks.com'': Connection refused > > I would appreciate any help on this..... the plug-in clearly > reimplements the auto_complete_for method, wich is exactly what I need > to do. > > Thanks in advance, > > Ildefonso Camargo > > On Oct 12, 7:58 am, "soulhunter" <ildefonso.cama...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi! > > > Thanks for your answer! > > > On Oct 11, 11:09 pm, "_Kevin" <kevin.olbr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > On Oct 11, 10:24 pm, "soulhunter" <ildefonso.cama...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi! > > > > > I would like to create a "custom" version of the "auto_complete_for" > > > > function, I took the source code, and altered it to my needs, and, off > > > > course, changed the name (fromauto_complete_forto > > > > custom_auto_complete_for , just for testing purporses). But rails keep > > > > complaining that the new method doesn''t exits! > > > > > I already did something similar with the "error_messages_for" function, > > > > and just wrote the new one in the application_helper.rb file, and just > > > > worked everywhere... but for theauto_complete_forfunction: I don''t > > > > know where to put it, I tried to put it in the helper, in the > > > > controller itself, and even in the model: no, it doesn''t work, like the > > > > function didn''t existed. > > > > > Any ideas? > > > > > Ildefonso Camargo > > > If you want to override the standard ''auto_complete_for:action, > > > :method'', all you have to do is define a method named > > > ''auto_complete_for_action_method'' in your controller and skip the > > > ''auto_complete_for'' line completely.Yes, I know, I already did that, but the thing is: I want to replace > > ALL the autocompletions in my project (more than 20), because I want to > > change the search conditions (from LIKE to ~* , and need to add some > > character substitution). > > > Thus, I tried to define this method (for testing purporses): > > > def custom_auto_complete_for(object, method, options = {}) > > define_method("auto_complete_for_#{object}_#{method}") do > > find_options = { > > :conditions => [ "#{method} ~* ? ", ''%'' + > > params[object][method].downcase + ''%''], > > :order => "#{method} ASC", > > :limit => 10 }.merge!(options) > > > @items = object.to_s.camelize.constantize.find(:all, find_options) > > > render :inline => "<%= auto_complete_result @items, ''#{method}'' %>" > > end > > end > > > That is my first approach, but when I try to call it, rails would just > > say: > > > undefined method `custom_auto_complete_for'' for > > ContribuyentesController:Class > > > and the log says: > > > NoMethodError (undefined method `custom_auto_complete_for'' for > > ContribuyentesController:Class): > > > I defined the method in application_helper.rb , but I also tried to > > define it locally in the "contribuyentes_controller.rb" file: I get the > > same error. > > > Thanks in advance, > > > Ildefonso Camargo--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Should be working now. If you still have trouble email me and I''ll send you a copy. _Kevin On Oct 13, 8:55 pm, "_Kevin" <kevin.olbr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''ll check on it. > > _Kevin > > On Oct 13, 3:14 pm, "soulhunter" <ildefonso.cama...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, again. > > > I just found this: > > >http://www.sciwerks.com/blog/2006/09/25/multiple_auto_complete_plugin/ > > > but I can''t download the plug-in :( . Does anybody has it?, the server > > just says: > > > script/plugin install > > svn://sciwerks.com/home/sciwerks/public_svn/plugins/multiple_auto_complete > > svn: Can''t connect to host ''sciwerks.com'': Connection refused > > > I would appreciate any help on this..... the plug-in clearly > > reimplements the auto_complete_for method, wich is exactly what I need > > to do. > > > Thanks in advance, > > > Ildefonso Camargo > > > On Oct 12, 7:58 am, "soulhunter" <ildefonso.cama...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi! > > > > Thanks for your answer! > > > > On Oct 11, 11:09 pm, "_Kevin" <kevin.olbr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Oct 11, 10:24 pm, "soulhunter" <ildefonso.cama...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > Hi! > > > > > > I would like to create a "custom" version of the "auto_complete_for" > > > > > function, I took the source code, and altered it to my needs, and, off > > > > > course, changed the name (fromauto_complete_forto > > > > > custom_auto_complete_for , just for testing purporses). But rails keep > > > > > complaining that the new method doesn''t exits! > > > > > > I already did something similar with the "error_messages_for" function, > > > > > and just wrote the new one in the application_helper.rb file, and just > > > > > worked everywhere... but for theauto_complete_forfunction: I don''t > > > > > know where to put it, I tried to put it in the helper, in the > > > > > controller itself, and even in the model: no, it doesn''t work, like the > > > > > function didn''t existed. > > > > > > Any ideas? > > > > > > Ildefonso Camargo > > > > If you want to override the standard ''auto_complete_for:action, > > > > :method'', all you have to do is define a method named > > > > ''auto_complete_for_action_method'' in your controller and skip the > > > > ''auto_complete_for'' line completely.Yes, I know, I already did that, but the thing is: I want to replace > > > ALL the autocompletions in my project (more than 20), because I want to > > > change the search conditions (from LIKE to ~* , and need to add some > > > character substitution). > > > > Thus, I tried to define this method (for testing purporses): > > > > def custom_auto_complete_for(object, method, options = {}) > > > define_method("auto_complete_for_#{object}_#{method}") do > > > find_options = { > > > :conditions => [ "#{method} ~* ? ", ''%'' + > > > params[object][method].downcase + ''%''], > > > :order => "#{method} ASC", > > > :limit => 10 }.merge!(options) > > > > @items = object.to_s.camelize.constantize.find(:all, find_options) > > > > render :inline => "<%= auto_complete_result @items, ''#{method}'' %>" > > > end > > > end > > > > That is my first approach, but when I try to call it, rails would just > > > say: > > > > undefined method `custom_auto_complete_for'' for > > > ContribuyentesController:Class > > > > and the log says: > > > > NoMethodError (undefined method `custom_auto_complete_for'' for > > > ContribuyentesController:Class): > > > > I defined the method in application_helper.rb , but I also tried to > > > define it locally in the "contribuyentes_controller.rb" file: I get the > > > same error. > > > > Thanks in advance, > > > > Ildefonso Camargo--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---