Hello!!! first of all sorry for my English! :-( Well I''m trying to make an auto_complete in my application, but it''s getting hard to do it. This is all what I''ve done: 1.I''m working with rails 2.1 and Postgres 2.My model name is: Alumno 3.My record name is: nombre in Alumno tables 4.I install the pluging with this command (http://wiki.rubyonrails.org/rails/pages/How+to+use+text_field_with_auto_complete): script/plugin install auto_complete 5.in my view (example.rhtml) <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>Mi boleta en la WEB</title> <%= javascript_include_tag :defaults %> <%= javascript_include_tag ''prototype'' %> <%= javascript_include_tag "scriptaculous/prototype" %> <%= javascript_include_tag "scriptaculous/scriptaculous" %> <%= javascript_include_tag ''scriptaculous'' %> <%= stylesheet_link_tag "example" %> <%= javascript_include_tag :all, :cache => true %> </head> <body> <%= text_field_with_auto_complete :alumno, :nombre, { :size => 15 }, :skip_style => true -%> </body> </html> 6. my model (alumno.rb) ActiveRecord::Base.establish_connection( :adapter => ''postgresql'', :host => ''localhost'', :port => "5432", :username=> ''XXXXX'', :password=> ''XXXXXX'', :database=> ''boletin'' ); class Alumno < ActiveRecord::Base end 7.my controller(completar_controller.rb) class CompletarController < ApplicationController auto_complete_for :alumno, :nombre, :limit => 15 def index @alumno = Alumno.new render :action => ''example'' end def auto_complete_for_alumno_nombre search = params[:alumno][:nombre] @nombres = Alumno.find(search) unless search.blank? render :partial => "result" end end 8.my partial (_result.rhtml) <ul class="autocomplete_list"> <% for nombre in @nombres .to_a -%> <li class="autocomplete_item"><%= nombre.nombre %> <% end -%> 9.my CSS (complete.css) .auto_complete { position:absolute; width:250px; background-color:white; border:1px solid #888; margin:0px; padding:0px; } .auto_complete ul { list-style-type: none; margin:0px; padding:0px; } .auto_complete ul li.selected { background-color: #bbf; } .auto_complete ul li { list-style-type: none; display:block; margin:0; padding:2px; height:16px; } That''s all I have. The problem is that, it doesn''t do anything, I can''t see anything in my text_field_with_auto_complete, it doesn''t show any error, can someone help me please I really want to get it right..thank you!! :-) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Please guys I need help with the auto_complete pluging, some ideas!!!! :-( -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Is your Alumno controller setup as a RESTful resource? If so, then the auto complete call won''t work because the auto_complete url isn''t one of the default routes created with a RESTful resource. You could explicitly add the route but I would suggest checking out this episode of Railscasts: http://railscasts.com/episodes/102-auto-complete-association It gives a straightforward approach to creating an auto complete field with a RESTful setup. Greg DeVore On Oct 1, 8:53 am, Juan Moreno <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Please guys I need help with the auto_complete pluging, some ideas!!!! > :-( > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
gdevore wrote:> Is your Alumno controller setup as a RESTful resource? If so, then > the auto complete call won''t work because the auto_complete url isn''t > one of the default routes created with a RESTful resource. You could > explicitly add the route but I would suggest checking out this episode > of Railscasts: > > http://railscasts.com/episodes/102-auto-complete-association >Alumnos is my table and belongs to a data base call Prueba, so my model is alumno.rb and my controller is completar_controller.rb, I will check the page that you recommend me, and try to do some changes, if it work I will tell you. Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Download Firebug, it''ll give you a much better idea of what''s going on http://getfirebug.com/ On Oct 1, 6:04 pm, Juan Moreno <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> gdevore wrote: > > Is your Alumno controller setup as a RESTful resource? If so, then > > the auto complete call won''t work because the auto_complete url isn''t > > one of the default routes created with a RESTful resource. You could > > explicitly add the route but I would suggest checking out this episode > > of Railscasts: > > >http://railscasts.com/episodes/102-auto-complete-association > > Alumnos is my table and belongs to a data base call Prueba, so my model > is alumno.rb and my controller is completar_controller.rb, I will check > the page that you recommend me, and try to do some changes, if it work I > will tell you. Thanks > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Juan Moreno wrote:> Hello!!! > > first of all sorry for my English! :-( > > Well I''m trying to make an auto_complete in my application, but it''s > getting hard to do it. This is all what I''ve done: > > 1.I''m working with rails 2.1 and Postgres > 2.My model name is: Alumno > 3.My record name is: nombre in Alumno tables > 4.I install the pluging with this command > (http://wiki.rubyonrails.org/rails/pages/How+to+use+text_field_with_auto_complete): > > script/plugin install auto_complete > > 5.in my view (example.rhtml) > <html xmlns="http://www.w3.org/1999/xhtml"> > <head> > <meta http-equiv="content-type" content="text/html; charset=utf-8" > /> > <title>Mi boleta en la WEB</title> > <%= javascript_include_tag :defaults %> > <%= javascript_include_tag ''prototype'' %> > <%= javascript_include_tag "scriptaculous/prototype" %> > <%= javascript_include_tag "scriptaculous/scriptaculous" %> > <%= javascript_include_tag ''scriptaculous'' %> > > <%= stylesheet_link_tag "example" %> > <%= javascript_include_tag :all, :cache => true %> > > </head> > <body> > > <%= text_field_with_auto_complete :alumno, :nombre, { :size => 15 }, > :skip_style => true -%> > > </body> > </html> > > 6. my model (alumno.rb) > ActiveRecord::Base.establish_connection( > :adapter => ''postgresql'', > :host => ''localhost'', > :port => "5432", > :username=> ''XXXXX'', > :password=> ''XXXXXX'', > :database=> ''boletin'' > ); > > > class Alumno < ActiveRecord::Base > > end > > 7.my controller(completar_controller.rb) > class CompletarController < ApplicationController > auto_complete_for :alumno, :nombre, :limit => 15 > def index > > @alumno = Alumno.new > render :action => ''example'' > end > > def auto_complete_for_alumno_nombre > search = params[:alumno][:nombre] > @nombres = Alumno.find(search) unless search.blank? > render :partial => "result" > end > > end > > 8.my partial (_result.rhtml) > <ul class="autocomplete_list"> > <% for nombre in @nombres .to_a -%> > <li class="autocomplete_item"><%= nombre.nombre %> > > <% end -%> > > 9.my CSS (complete.css) > > .auto_complete { > position:absolute; > width:250px; > background-color:white; > border:1px solid #888; > margin:0px; > padding:0px; > } > > .auto_complete ul { > list-style-type: none; > margin:0px; > padding:0px; > } > > .auto_complete ul li.selected > { > background-color: #bbf; > > } > > .auto_complete ul li { > list-style-type: none; > display:block; > margin:0; > padding:2px; > height:16px; > } > > That''s all I have. The problem is that, it doesn''t do anything, I can''t > see anything in my text_field_with_auto_complete, it doesn''t show any > error, can someone help me please I really want to get it right..thank > you!! :-)Hi Juan. As I''m fairly new to RoR I may not be the right one to solve your problem. But since you ask so direct here is what I did: I got inspired by (more or less copied) this example: http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/65f6f9011fa78b41/d45c3f04c2eacf4a?lnk=gst&q=text_field_with_auto_complete#d45c3f04c2eacf4a Especially this part about the "auto_complete" method: def auto_complete_for_person_name @people = Person.find(:all, :conditions => ["name LIKE ? AND org = ?", "#{params[:person] [:name]}%", params[:person][:org]], :order => "name ASC") unless @people.blank? render :inline => "<%= content_tag(:ul, @people.map{|person| content_tag(:li, h(person)) }) %>" else render :inline => "" end end Remember I''m using Rails ver 1.2.6 - so it may not work for your version. Good Luck! Peter -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Couple of things a) Your stylesheet is called complete.css but your stylesheet_link_tag says "example" ? b) Check your logs as you type to see if rails fires off queries depending on your input.. The autocomplete method is doing a "find" which should be firing off SQLs in ur log file. You would atleast know if that part of it is working. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
hello guys!!! it''s me again, I still have problem with my auto_complete, but finally I got an error, these is what firebug says <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Action Controller: Exception caught</title> <style> body { background-color: #fff; color: #333; } body, p, ol, ul, td { font-family: verdana, arial, helvetica, sans-serif; font-size: 13px; line-height: 18px; } pre { background-color: #eee; padding: 10px; font-size: 11px; } a { color: #000; } a:visited { color: #666; } a:hover { color: #fff; background-color:#000; } </style> </head> <body> <h1> ActionController::InvalidAuthenticityToken in PruebaController#auto_complete_for_alumno_nombre </h1> <pre>ActionController::InvalidAuthenticityToken</pre> <p><code>RAILS_ROOT: /home/jpmg/ruby/completar</code></p> <div id="traces"> <a href="#" onclick="document.getElementById(''Framework-Trace'').style.display=''none'';document.getElementById (''Full-Trace'').style.display=''none'';document.getElementById(''Application-Trace'').style.display=''block'' ;; return false;">Application Trace</a> | <a href="#" onclick="document.getElementById(''Application-Trace'').style.display=''none'';document.getElementById (''Full-Trace'').style.display=''none'';document.getElementById(''Framework-Trace'').style.display=''block'' ;; return false;">Framework Trace</a> | <a href="#" onclick="document.getElementById(''Application-Trace'').style.display=''none'';document.getElementById (''Framework-Trace'').style.display=''none'';document.getElementById(''Full-Trace'').style.display=''block'' ;; return false;">Full Trace</a> <div id="Application-Trace" style="display: block;"> <pre><code></code></pre> </div> <div id="Full-Trace" style="display: none;"> <h2 style="margin-top: 30px">Request</h2> <p><b>Parameters</b>: <pre>{"alumno"=>{"nombre"=>"K"}}</pre></p> <p><a href="#" onclick="document.getElementById(''session_dump'').style.display=''block''; return false;">Show session dump</a></p><div id="session_dump" style="display:none"><pre class=''debug_dump''>--- :csrf_id: c55efda528b897a47f929b3d45f8b6aa flash: !map:ActionController::Flash::FlashHash {} </pre></div> <h2 style="margin-top: 30px">Response</h2> <p><b>Headers</b>: <pre>{"cookie"=>[], "Cache-Control"=>"no-cache"}</pre></p> </body> </html> can someone help me please I really want to get it right..thank you!! :-) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Finally works!!!!!!! these is all I did 1.controller auto_complete_for :alumno, :nombre protect_from_forgery :only => [:create, :delete, :update] 2.in my view <%= text_field_with_auto_complete :alumno, :nombre, {}, {:method => :get} %> 3.in my route map.resources :alumnos, :collection => {:auto_complete_for_alumno_nombre => :get } and that''s it. Thanks to all..... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---